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>
点击事件,渲染结果onclick="edit('23')"
<td><a th:onclick="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");
Thymeleaf在html中的输出
猜你喜欢
转载自theseus.iteye.com/blog/2379396
今日推荐
周排行