对象数据
th:text="${user.username}"
th:text="${user['username']}"
th:object="${user}" th:text="*{username}"
list集合数据
th:text="${list.get(0)}"
th:text="${list[1]}"
map集合数据
th:text="${map['key1']}"
th:text="${map.key2}"
静态资源
src="/static/imgs/1.jpg"
模板的内置对象
th:text="${#session.getAttribute('sessionuser').username}"
th:text="${session.sessionuser.username}"
工具内置对象
th:text="${#dates.format(date,'yyyy-MM-dd')}"
th:text="${#dates.createNow()}"
th:text="${#dates.createToday()}"
URL链接
th:src="@{/static/imags/1.jpg}"
th:href="@{/url(username=jack,password=123)}"
th:href="@{/url/{username}/{password}(username=tom,password=000)}"
if的使用
th:if="${sex==0}"
switch case的使用
th:switch="${sex}"
th:case="0"
算术运算
th:text="${1+2}"
定义参数
th:with="sum=2+2" th:text="${sum}"
迭代
th:each="str:${list}"
th:text="${str}"
三目运算符
th:text="${sex==0?'男':'女'}"
样式操作
th:class="red"
value属性
th:type="text" th:value="请输入用户名"
布尔值修复
th:checked="${sex==0}"
js的onclick方法
h:onclick="'buy('+${pro.pid}+','+${pro.price}+')'"
SpringBoot——【thymeleaf】——基础语法
最新推荐文章于 2022-10-29 21:52:37 发布