<head th:include="相对于templates的地址/include :: header"></head> <div th:include="album/include :: footer"></div>
th:include 和 th:replace 都可以引入模块,两者的区别在于:
th:include:引入子模块的 children,依然保留父模块的 tag
th:replace:引入子模块的所有,不保留父模块的 tag
举个例子
<footer th:fragment="copy">
© 2018 Copyright by holyong.
</footer>
引入界面
<body>
...
<div th:include="footer :: copy"></div>
<div th:replace="footer :: copy"></div>
</body>
显示结果
<body>
...
<div>
© 2018 Copyright by holyong.
</div>
<footer>
© 2018 Copyright by holyong.
</footer>
</body>