首页 > 其他 > 详细

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

时间:2018-02-24 11:21:01      阅读:3228      评论:0      收藏:0      [点我收藏+]

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

例子

    <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>

 依次导入

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

结果

    <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>    

 

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

原文:https://www.cnblogs.com/ydymz/p/8464744.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!