3.7 模板布局
3.7.1 th:fragment
<body><div th:fragment&#61;"copy">© 2011 The Good Thymes Virtual Grocerydiv>
body>
3.7.2 th:include and th:replace
<div th:insert&#61;"~{footer :: copy}">div>
<div th:insert&#61;"footer :: copy">div>
3.7.3 th:remove
th:remove
可以以五种不同的方式行事&#xff0c;具体取决于它的价值all
&#xff1a;删除包含标签及其所有子项。body
&#xff1a;不要删除包含的标签&#xff0c;但删除其所有的孩子。tag
&#xff1a;删除包含的标签&#xff0c;但不要删除其子项。all-but-first
&#xff1a;除去第一个包含标签的所有子项。none
&#xff1a; 没做什么。该值对于动态评估是有用的。
<tr th:remove&#61;"all"><td>Mild Cinnamontd><td>1.99td><td>yestd>
tr><a href&#61;"/something" th:remove&#61;"${condition}? tag : none">Link text not to be removeda>
3.8 th:with
1.可一次定义多个,逗号分隔
<div th:with&#61;"firstPer&#61;${list[0]}"> <p>The name of the first person is <span th:text&#61;"${firstPer.userName}">Julius Caesarspan>.p>
div>
<div th:with&#61;"firstPer&#61;${list[0]},secondPer&#61;${list[1]}"> <p>The name of the first person is <span th:text&#61;"${firstPer.userName}">Julius Caesarspan>.p> <p> But the name of the second person is <span th:text&#61;"${secondPer.userName}">Marcus Antoniusspan>. p>
div>
2.可复用
<div th:with&#61;"company&#61;${user.company},account&#61;${accounts[company]}"> <div th:text&#61;"${company}">div> <div th:text&#61;"${account}">div>
div>
3.9 属性优先级