当前位置:网站首页>th:include的使用

th:include的使用

2022-07-08 00:53:00 海涛高软

<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">
&copy; 2018 Copyright by holyong.
</footer>

引入界面

<body>
...
<div th:include="footer :: copy"></div>
<div th:replace="footer :: copy"></div>
</body>

显示结果

<body>
...
<div>
&copy; 2018 Copyright by holyong.
</div>
<footer>
&copy; 2018 Copyright by holyong.
</footer>
</body>
原网站

版权声明
本文为[海涛高软]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_15267341/article/details/125611975