Thymeleaf在html中的输出

thymeleaf在页面中输出格式th:field,其中filed是各标签中的属性
1、在table中遍历List
<tr th:each="item,itemStat : ${list}">
输出序列号
<td th:text="${itemStat.count}">序号</td>
输出变量值
<td th:text="${item.code}">代码</td>
点击事件,渲染结果οnclick="edit('23')"
<td><a th:οnclick="edit+'(' +'\''+${item.code}+'\'' +')'">>编辑</a></td>
2、if-else可以使用switch-case来实现
<div th:switch="${editable}">
<div th:case="true">true</div>
<div th:case="false">false</div>
</div>
3、js中赋值
<script th:inline="javascript">
var msg = [[${msg}]];
</script>
注:${}中的变量都是从后台传入的,在SpringMVC中:
ModelAndView mav = new ModelAndView("/pagepath");
mav.addObject("msg", "error");
4、thymeleaf中输出html标签 使用th:utext
<p th:utext="#{home.welcome}">Welcome to our grocery store!</p>
效果:<p>Welcome to our <b>fantastic</b> grocery store!</p>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值