引入:
<html lang="en" xmlns:th="http://www.thymeleaf.org">
1.公共片段
定义公共代码
<div id = "code">公共代码</div>
引入
<div th:repace="文件名 :: #code"></div>
2.循环
<ul>
<li th:each="user : ${userList}" th:text="${user.userName}"></li>
</ul>
3.条件判断
<h3 th:if="not ${#lists.isEmpty(userList)}">list有值</h3>
4.session
<div th:object="${session.user}">
<p>
姓名:<span th:text="*{username}">xxxx</span>
</p>
<p>
性别:<span th:text="*{gender == 1 ? '女' : '男'}">xxxx</span>
</p>
</div>