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')"

技术
今日推荐
PPT
阅读数 121
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信