網站首頁 編程語言 正文
thymeleaf中th:include, th:insert, th:replace的區別
一、代碼和介紹
- footer.html
<footer th:fragment="copy">
需要copy的代碼...
</footer>
- 需要引用copy的頁面,有三種方式
- 【注意】這里的footer是頁面的名稱,不是標簽的名稱
<body>
...其他代碼
<div th:insert="footer :: copy"></div>
<div th:replace="footer :: copy"></div>
<div th:include="footer :: copy"></div>
</body>
-
渲染后的效果
-
th:insert
- 相當于把需要引入的內容,標簽+代碼一同引如到div內部
<div> <footer th:fragment="copy"> 需要copy的代碼... </footer> </div>
-
th:replace
-
th:replace
是在div標簽上寫的,渲染效果則是用footer把div替換掉
<footer th:fragment="copy"> 需要copy的代碼... </footer>
-
-
th:include
- 將footer標簽體內的內容,放到div中進行渲染,div中原先有的內容也會被覆蓋掉
<div> <footer th:fragment="copy"> 需要copy的代碼... </footer> </div>
-
二、演示截圖
- 代碼截圖
- chrome瀏覽器中渲染后的結果
原文鏈接:https://blog.csdn.net/BlackBox_/article/details/122111384
相關推薦
- 2022-08-26 深入理解React調度(Scheduler)原理_React
- 2022-12-12 React?高階組件與Render?Props優缺點詳解_React
- 2022-10-06 C#中?MessageBox的使用技巧_C 語言
- 2022-06-17 Go語言學習之函數的定義與使用詳解_Golang
- 2022-10-26 Golang?基于flag庫實現一個簡單命令行工具_Golang
- 2021-12-28 Go語言做爬蟲狀態碼返回418的問題解決_Golang
- 2022-05-11 mac zsh: command not found: vim
- 2022-12-05 Android?Crash與ANR詳細介紹_Android
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支