1
我有一张表和一个多行数据集。我不想跨越此表的所有行。所以,我创建了一个柜台,但我在,如果条件得到一个错误:百里香显示表格的顶部k行
<div th:if="${dataset}" th:with="counter=0">
<table class="table">
<tbody>
<th:block th:each="t_log : ${dataset.rows}" th:with="counter=${counter} + 1">
<tr th:if="${counter <= 5 }">
<td th:text="${t_log.title}"/>
<td th:if="${t_log.msg == '1'}" th:text="Online"/>
<td th:if="${t_log.msg == '0'}" th:text="Offline"/>
</tr>
</th:block>
</tbody>
</table>
</div>
我从这里看到一个例子:
但我的计数器不会做的伎俩。
是因为我看到,如果你不添加额外的iterstat,thymeleaf对变量t_log,t_logStat.count隐藏状态做这项工作。 – bill 2015-03-20 09:33:12
我实际上更喜欢使用明确的Stat变量:th:each =“t_log,t_logStat:$ {dataset.rows}”和th:if =“$ {t_logStat.count} le 5”。 t_logStat有各种有用的变量,count(从1开始),index(从0开始)等等。 – 2016-08-02 17:19:14