thymeleaf th:replace th:include

2018-12-17  本文已影响0人  marjorie叶子

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

<span style="font-family:SimHei;font-size:18px;">需要替换的片段内容:  
<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>    
  
</span> 
上一篇 下一篇

猜你喜欢

热点阅读