thymeleaf循环遍历
2019-02-27 10:38
791 查看
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>
相关文章推荐
- thymeleaf循环遍历
- 循环遍历数组方法
- 循环遍历form元素里的表单元素
- jquery 实现Ajax,JS 循环遍历JSON数据
- 用angularjs在循环遍历中绑定ng-model(转载---CSDN博客 )
- 求像数据集一样循环遍历XML的方法
- 循环遍历数据库中数据
- 无限循环遍历数组(正序|倒序)先加后减原则
- spark中mapPartitions双重循环或两次遍历(duplicate)
- SQL Server中的系统表sysobjects使用方法,实现循环遍历所有表(转)
- Python中list循环遍历中删除数据报溢出异常
- 遍历list 造成的死循环
- 【转】ArrayList和LinkedList的几种循环遍历方式及性能对比分析
- leetcode 133. Clone Graph 图遍历BFS + 避免循环
- jsp循环遍历后台List结果的三种常用方法
- jsp如何循环遍历html元素
- PHP循环遍历数组的3种方法list()、each()和while总结
- HashMap循环遍历方式及其性能对比
- java的加强型循环遍历(反向遍历)
- for-in 来遍历字典 while for 循环