zoukankan      html  css  js  c++  java
  • 关于thymeleaf th:replace th:include th:insert 的区别

    关于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>    
    
  • 相关阅读:
    02_5if switch分支与循环语句
    02_4运算符
    02_3程序格式
    Shell脚本调用ftp上传文件
    02_2数据类型转换
    02_1标识符_关键字_数据类型
    01_3Java Application初步
    01_2Java开发环境的下载 安装 配置
    Mac 安装MySQL
    用 Homebrew 带飞你的 Mac
  • 原文地址:https://www.cnblogs.com/ydymz/p/8464744.html
Copyright © 2011-2022 走看看