前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >关于thymeleaf th:replace th:include th:insert 的区别

关于thymeleaf th:replace th:include th:insert 的区别

作者头像
ydymz
发布2018-09-10 16:03:20
1.2K0
发布2018-09-10 16:03:20
举报
文章被收录于专栏:lgp20151222lgp20151222

关于thymeleaf th:replace th:include th:insert 的区别     th:insert   :保留自己的主标签,保留th:fragment的主标签。     th:replace :不要自己的主标签,保留th:fragment的主标签。     th:include :保留自己的主标签,不要th:fragment的主标签。(官方3.0后不推荐)

例子

代码语言:javascript
复制
    <span style="font-family:SimHei;font-size:18px;">需要替换的片段内容:  

//copy代码片
    <footer th:fragment="copy">  
       <script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>  
    </footer>  

 依次导入

代码语言:javascript
复制
      <div th:insert="footer :: copy"></div>  
      
      <div th:replace="footer :: copy"></div>  
     
      <div th:include="footer :: copy"></div>  

结果

代码语言:javascript
复制
    <div>  
        <footer>  
           <script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>  
        </footer>    
    </div>    
      
    <footer>  
      <script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>  
    </footer>    
      
    <div>  
      <script type="text/javascript" th:src="@{/plugins/jquery/jquery-3.0.2.js}"></script>  
    </div>    
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-02-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档