抽取公共内容---thymeleaf
声明重复片段
<!--引用时要在名称id前加上 #
<div th:instert="comon :: #commonheader"></div>
文件名 片段名称
-->
<head id="commonheader">
<footer th:fragment="commonscript">
© 2011 The Good Thymes Virtual Grocery
</footer>
引用重复片段
<div th:instert="comon :: commonscript"></div>
<div th:replace="comon :: commonscript"></div>
<div th:include="comon :: commonscript"></div>
instert:在当前标签中加入重复片段中包含标签的文本内容
<div>
<footer>
© 2011 The Good Thymes Virtual Grocery
</footer>
</div>
replace:将当前标签替换为重复片段中包含标签的文本内容
<footer>
© 2011 The Good Thymes Virtual Grocery
</footer>
include:在当前标签中加入重复片段中不包含标签的文本内容
<div>
© 2011 The Good Thymes Virtual Grocery
</div>

浙公网安备 33010602011771号