Thymeleaf碎片使用

碎片原理:

head.html页面要进行碎片化处理(th:fragment="fragment1"   fragment1为index.html页面引用)

<div th:fragment="fragment1">
<span style="background: aqua"> this is header!</span>
</div>

index.html( th:include="head::fragment1"中的head为head.html的前缀,必须保持一致。)

<div id="header" th:include="head::fragment1"></div>

include引用碎片标签中的内容,replace为替换当前的碎片标签。
原文地址:https://www.cnblogs.com/Fisherman13/p/13065539.html