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

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