项目使用Thymeleaf模板,页面只需要显示list里面的前3条数据,这时候应该怎么做呢,不像jsp那样,可以使用begin=“0”,end=“2”
这样,这时候可以使用 th:if="${userStat.index} lt 3 判断当前的迭代索引,从0开始。这是index属性。lt 就是
<,这样就可以获取前3 条数据了。
<tr th:each="user,userStat:${supplierVotes}" th:class="${userStat.odd}? 'odd'"
th:if="${userStat.index} lt 3" th:object="${user}"> <td
th:text="${userStat.count}">1</td> <a
th:href="@{/user/details(customerId=${user.customerId})}" target="_blank"><td
th:text="*{customerId}">1</td></a> <td th:text="${user.yearFlag}">1</td> <td
th:text="|${user.yearFlag} ${user.customerId}|">1</td> <td><span
th:if="${user.yearFlag == '2017'}">特殊提供</span></td> <td><a
th:href="@{/user/details(customerId=${user.customerId})}"
target="_blank">详情</a></td> </tr>

技术
今日推荐
PPT
阅读数 119
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信