using thymeleaf 之 th:each迭代循环
来源:互联网 发布:js鼠标滚动条事件 编辑:程序博客网 时间:2024/05/22 00:20
th:each属性用于迭代循环,语法:th:each="obj,iterStat:${objList}"
迭代对象可以是java.util.List,java.util.Map,数组等;
iterStat称作状态变量,属性有:
index:当前迭代对象的index(从0开始计算)
count: 当前迭代对象的index(从1开始计算)
size:被迭代对象的大小
current:当前迭代变量
even/odd:布尔值,当前循环是否是偶数/奇数(从0开始计算)
first:布尔值,当前循环是否是第一个
last:布尔值,当前循环是否是最后一个
<ol><li>List循环:<table border="1"> <tr> <th>用户名</th> <th>邮箱</th> <th>管理员</th> <th>状态变量:index</th> <th>状态变量:count</th> <th>状态变量:size</th> <th>状态变量:current.userName</th> <th>状态变量:even</th> <th>状态变量:odd</th> <th>状态变量:first</th> <th>状态变量:last</th> </tr> <tr th:each="user,userStat : ${list}"> <td th:text="${user.userName}">Onions</td> <td th:text="${user.email}">test@test.com.cn</td> <td th:text="${user.isAdmin}">yes</td> <th th:text="${userStat.index}">状态变量:index</th> <th th:text="${userStat.count}">状态变量:count</th> <th th:text="${userStat.size}">状态变量:size</th> <th th:text="${userStat.current.userName}">状态变量:current</th> <th th:text="${userStat.even}">状态变量:even****</th> <th th:text="${userStat.odd}">状态变量:odd</th> <th th:text="${userStat.first}">状态变量:first</th> <th th:text="${userStat.last}">状态变量:last</th> </tr> </table></li><li>Map循环:<div th:each="mapS:${map}"><div th:text="${mapS}"></div></div></li><li>数组循环:<div th:each="arrayS:${arrays}"><div th:text="${arrayS}"></div></div></li></ol>
0 2
- using thymeleaf 之 th:each迭代循环
- 如何使用th:each属性迭代模板-原标题:How To Use th:each For Iteration In Thymeleaf Template?
- each()循环 迭代
- using thymeleaf之六th:text/th:utext属性
- java鬼混笔记:springboot之thymeleaf 3:th:each遍历
- thymeleaf中的th:each用法
- using thymeleaf之八th:with定义局部变量
- using thymeleaf之七设置属性的值(th:attr/th:value/th:alt-title/th:attrappend/th:attrprepend/th:checked)
- 迭代循环-Thymeleaf常见用法(四)
- Thymeleaf中的迭代
- thymeleaf模板引擎div th:each=展示echarts图表
- JAVA中的for-each循环与迭代
- using thymeleaf之三文字
- using thymeleaf之十一内联
- thymeleaf标签之th:href的使用
- thymeleaf标签之th:text的使用
- using thymeleaf之二简单表达式
- using thymeleaf之四操作符
- 指针初识6(指针与多维数组)
- 第十周项目6-贪财的富翁
- 求小数的循环节
- POJ 1849 Two(遍历树)
- Java基础-将Bean属性值放入Map中
- using thymeleaf 之 th:each迭代循环
- 手写快速排序【随机数作基数】
- hdu 4771 Stealing Harry Potter's Precious(bfs+枚举)
- 中文分词实现——双向最大匹配
- 的个电饭锅
- [jbb0523整理]压缩感知中的数学知识:NP-hard问题
- 日语学习之新版初级标准日本语-6 吉田さんは来月中国へ
- 第10周项目 逗你玩
- hdu2674 N!Again