728x90
반응형
반복문 (th:each="변수[, 상태변수] : ${콜렉션객체}")
- 상태변수의 속성. 다른 속성은 직관적으로 알 수 있고,
- current 데이터가 조금 낯선데 이건 설명처럼 변수와 같은 속성이다. 그래서 변수와 비교하면 true가 나온다.
- The current iteration index, starting with 0. This is the index property.
- The current iteration index, starting with 1. This is the count property.
- The total amount of elements in the iterated variable. This is the size property.
- The iter variable for each iteration. This is the current property.
- Whether the current iteration is even or odd. These are the even/odd boolean properties.
- Whether the current iteration is the first one. This is the first boolean property.
- Whether the current iteration is the last one. This is the last boolean property.
<table> <thead><tr> <th>아이디</th><th>index</th> <th>count</th><th>even</th> <th>odd</th><th>first</th> <th>last</th><th>current</th><th>size</th> </tr></thead> <tbody> <tr th:each="user, userStat : ${list}"> <td><span th:text="${user.userId}"></span></td> <td><span th:text="${ userStat.index }"></span></td> <td><span th:text="${ userStat.count }"></span></td> <td><span th:text="${ userStat.even }"></span></td> <td><span th:text="${ userStat.odd }"></span></td> <td><span th:text="${ userStat.first }"></span></td> <td><span th:text="${ userStat.last }"></span></td> <td><span th:text="${ userStat.current == user }"></span></td> <td><span th:text="${ userStat.size }"></span></td> </tr> </tbody> </table>
728x90