首页 > 其他 > 详细

thymeleaf引入公共页面的某个片段

时间:2019-11-13 10:07:45      阅读:133      评论:0      收藏:0      [点我收藏+]

引入公共片段
引入公共片段的th属性,包括三种方式

th:insert
将公共片段,整个插入到声明引入的元素中

th:replace
将声明引入的元素,替换为公共片段

th:include
将被引入的片段的内容,包含进这个标签中

抽取公共片段

 <footer th:fragment="copy">
  2011
 </footer>

引入方式

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

引入语法~{模板名(即html)::片段名} 
波浪线、花括号可以写,可以不写

但是,在行内写法中[[~{}]]、[(~{})] 
必须,加上~{}

thymeleaf引入公共页面的某个片段

原文:https://www.cnblogs.com/wangchaoqi/p/11846955.html

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