thymeleaf语法简单使用
集合的非空判断
th:if="${not #lists.isEmpty(自定义集合)}"
字符串拼接
<span th:text="|Welcome to home, ${user.name}!|">
//这实际上相当于:
<span th:text="'Welcome to home, ' + ${user.name} + '!'">
//文字替换可以与其他类型的表达相结合:
<span th:text="${onevar} + ' ' + |${twovar}, ${threevar}|">
小数(四舍五入)
//显示1.24
th:text="${#numbers.formatDecimal(1.235, 1, 2)}"
a标签-超链接
//显示1.24
<a th:href="@{/companyUser/getUserByUserName/(id=${companyUser.id},userName=${companyUser.userName})}">view</a>
<a th:href="@{/companyUser/{companyUser.id}/getUserByUserName>view</a>
三元运算符判断
th:text="'Execution mode is ' + ( ('0'!='0')? 'Development' : 'Production')"