SpringBoot thymeleaf usage method, thymeleaf template iteration
SpringBoot thymeleaf loop List, Map
================================
©Copyright Sweet Potato Yao March 26, 2018
http://fanshuyao.iteye.com/
1. The thymeleaf template basically displays:
<div th>thymeleaf template language test</div> Hello <div>, <span class="cc" id="aaa" th:text="${myname}" th:id="${id}"></span> </div> <div class="cc" id="bbb" th:text="'姓名:'+${myname}" th:id="'id_'+${id}"></div>
2. Iterate List
<div>==========List iteration==============</div> <ul> <li th:each="data : ${list}" th:text="${data}"></li> </ul>
3. Iteration of the students collection object
<div>==========students iteration==============</div> <ul> <li th:each="student : ${students}" th:text="'姓名:' + ${student.name} + ',年龄:' + ${student.age}"></li> </ul>
4. The second way to iterate the students collection object is to use double vertical bars: |xxxx|
<div>==========students iteration 2, using double vertical bars: |xxxx|==============</div> <ul> <li th:each="student : ${students}" th:text="|姓名:${student.name} ,年龄: ${student.age}|"></li> </ul>
5. The third way to iterate the students collection object, use square brackets: [[]] or [()], the difference between these two is whether to escape special characters
<div>==========students iteration 3, use square brackets: [[]] or [()]================</div> <ul> <li th:each="student : ${students}" >姓名:[[${student.name}]],年龄:[(${student.age})]</li> </ul>
6. Map iteration
<div>==========Map iteration==============</div> <ul> <li th:each="m : ${map}" >key:[[${m.key}]],值:[(${m.value})]</li> </ul>
7. Basic usage of template language: (attached in Pdf document: usingthymeleaf.pdf)
1. Basic syntax:
2. Corresponding properties:
================================
©Copyright Sweet Potato Yao March 26, 2018
http://fanshuyao.iteye.com/