java - Thymeleaf中each标签遍历list如何获取index
大家讲道理
大家讲道理 2017-04-17 15:16:33
0
2
776

应用程序采用sprigmvc,Thymeleaf来作为view层的数据展示。页面中试用th:each标签来遍历后端传来的List。需要取到index。

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
大家讲道理

<tr th:each="user,userStat:${users}">
userStat is a status variable with attributes such as index, count, size, current, even, odd, first, last, etc. If the status variable is not set explicitly, thymeleaf will default to "variable name + Stat" "'s state variable.

Peter_Zhu

The official document I read here is that the state variables are called iterStat by default. It is possible to test it yourself.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!