Thymeleaf引入公共片段方式
生活随笔
收集整理的這篇文章主要介紹了
Thymeleaf引入公共片段方式
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
引入公共片段
引入公共片段的th屬性,包括三種方式
th:insert
將公共片段,整個(gè)插入到聲明引入的元素中
th:replace
將聲明引入的元素,替換為公共片段
th:include
將被引入的片段的內(nèi)容,包含進(jìn)這個(gè)標(biāo)簽中
抽取公共片段
<footer th:fragment="copy"> © 2011 The Good Thymes Virtual Grocery </footer>引入方式
<div th:insert="footer :: copy"></div> <div th:replace="footer :: copy"></div> <div th:include="footer :: copy"></div>頁面效果
<div> <footer> © 2011 The Good Thymes Virtual Grocery </footer> </div><footer> © 2011 The Good Thymes Virtual Grocery </footer><div> © 2011 The Good Thymes Virtual Grocery </div>注意
引入語法~{}
波浪線、花括號(hào)可以寫,可以不寫
但是,在行內(nèi)寫法中[[~{}]]、[(~{})]
必須,加上~{}
總結(jié)
以上是生活随笔為你收集整理的Thymeleaf引入公共片段方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Thymeleaf抽取公共页面片段
- 下一篇: Thymeleaf选择器引用公共片段