Spring Boot Thymeleaf 公共布局
Spring Boot Thymeleaf About 1,180 wordsfragment
定义公共模板footer.html,位于resources/templates/portal文件夹下。
<footer class="footer">
<p>
<th:block th:text="'©' + ${#temporals.year(#temporals.createNow())}"></th:block>
<a th:if="${@portal.icp}" th:text="${@portal.icp.getId()}" th:href="${@portal.icp.getLink()}" target="_blank"></a>
<a style="color:#4CAF50;" href="https://www.aliyun.com/minisite/goods?userCode=id54txo0"
target="_blank">阿里云</a>
</p>
<p>
<th:block th:if="${@portal.comment.enabled}">
<a th:if="${@portal.comment.type == 'giscus'}" href="/message-board.html" title="留言板"></a>
<a href="/sitemap.xml">网站地图</a>
<a th:if="${@portal.github}" th:href="${@portal.github}" target="_blank">GitHub</a>
</th:block>
</p>
</footer>
insert
在其他HTML文件中使用th:insert引入footer,<footer></footer>会被包裹在div中。
<div th:insert="~{portal/footer}"></div>
replace
在其他HTML文件中使用th:replace引入footer,则div不会被渲染,而是直接渲染<footer></footer>。
<div th:replace="~{portal/footer}"></div>
Views: 1,382 · Posted: 2023-08-16
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...