在展示資料的的時候想到,序号總不能按照資料庫的id走吧。而且有可能id為字元串,是以應該是前端頁面根據循環體的長度實作自增。查詢後發現
h:each屬性用于疊代循環,文法:
th:each="obj,itemStat:${objList}
itemStat稱作狀态變量,屬性有:
index:目前疊代對象的index(從0開始計算)
count: 目前疊代對象的index(從1開始計算)
size:被疊代對象的大小
current:目前疊代變量
even/odd:布爾值,目前循環是否是偶數/奇數(從0開始計算)
first:布爾值,目前循環是否是第一個
last:布爾值,目前循環是否是最後一個
是以代碼為
<tbody th:each="connection,connectionStart:${connectionList}">
<tr>
<td th:text="${connectionStart.count}"></td>
<td th:text="${connection.conname}"></td>
<td th:text="${connection.contype}"></td>
</tr>