footer.html <div th:fragment="common"> <select class="selectpicker"> <option>Mustard</option> <option>Ketchup</option> <option>Barbecue</option> </select> </div> //直接加载 <th:block th:include="footer :: common" /> //放到div 里 <div th:include="footer :: common"></div>
//footer为路径,以resources/templates/为根目录
如文件放在 resources/templates/abc/footer.html
<th:block th:include="/abc/footer :: common" />
common为th:fragment="common"的common,表示加载这里面的内容
//传值写法 select 的nane 传source <th:block th:include="labelThymeleaf :: common('source')" /> //用户th:name="${name}"赋值 <div th:fragment="common(name)"> <select th:name="${name}" class="selectpicker"> <option>Mustard</option> <option>Ketchup</option> <option>Barbecue</option> </select> </div> //正式环境可能报路径错误 将<th:block th:include="labelThymeleaf :: common('source')" /> 写法,改成元素包裹 路径区分大小写并且首行无/ <span th:include="IpManagement/labelThymeleaf :: commonSource('source')" />
关注"都市百货" 了解南陵
微信咨询wanglf2r(不拉群 发广告者勿加)
热门评论