thymeleaf显示表格,for循环

https://blog.csdn.net/u010002184/article/details/80675661


<div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr>
                        <th>id</th>
                        <th>创建用户名</th>
                        <th>更新用户名</th>
                        <th>登录名</th>
                        <th>暱称</th>
                        <th>邮编</th>
                        <th>状态变量:index</th>
                        <th>状态变量:count</th>
                        <th>状态变量:size</th>
                        <th>状态变量:even</th>
                        <th>状态变量:odd</th>
                        <th>状态变量:first</th>
                        <th>状态变量:last</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="info,infoStat :${infopage}">
                        <td th:text="${info.id}"></td>
                        <td th:text="${info.createUser}"></td>
                        <td th:text="${info.createUser}"></td>
                        <td th:text="${info.username}"></td>
                        <td th:text="${info.nickname}"></td>
                        <td th:text="${info.email}"></td>
                        <th th:text="${infoStat.index}"></th>
                        <th th:text="${infoStat.count}"></th>
                        <th th:text="${infoStat.size}"></th>
                        <th th:text="${infoStat.even}"></th>
                        <th th:text="${infoStat.odd}"></th>
                        <th th:text="${infoStat.first}"></th>
                        <th th:text="${infoStat.last}"></th>
                    </tr>
                    </tbody>
                </table>
            </div>

thymeleaf显示表格,for循环

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:布尔值,当前循环是否是最后一个

参考:

using thymeleaf 之 th:each迭代循环  https://blog.csdn.net/sun_jy2011/article/details/40710429
Thymeleaf的内置属性(转) https://www.cnblogs.com/mochaMM/p/5054499.html 
Thymeleaf基础 遍历List、Map、List<map>、Map<List> https://blog.csdn.net/u012485114/article/details/53906250

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章