在展示数据的的时候想到,序号总不能按照数据库的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>