일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- linux
- BindingResult
- 프로젝트 클린
- 타임리프
- 룸북
- 함수 인자값 id
- 타임리프와 스프링
- Intellij
- 순서 보장
- 하모니카 OS 5
- 비밀번호 변경 명령어
- it
- 시퀀스 조회
- 개발시작전 자세
- 스프링부트
- 다른사람 프로젝트 수정전 가져야할 자세
- Java
- js
- 추천 프로그램
- StringUtils.hasText
- 추천 사이트
- Test 룸북 사용하기
- select
- #{..}
- 자바스크립트 인라인
- cmd
- 명령어
- 설정
- JSON
- 리눅스
Archives
- Today
- Total
웹개발 블로그
[Thymeleaf] 반복 본문
반복 상태 유지
<tr th:each="user, userStat : ${users}">
반복의 두번째 파라미터를 설정해서 반복의 상태를 확인 할 수 있습니다.
두번째 파라미터는 생략 가능한데, 생략하면 지정한 변수명( user ) + Stat 가 됩니다.
💥여기서는 user + Stat = userStat 이므로 생략 가능합니다.💥
# 반복 상태 유지 기능
index : 0부터 시작하는 값
count : 1부터 시작하는 값
size : 전체 사이즈
even , odd : 홀수, 짝수 여부( boolean )
first , last :처음, 마지막 여부( boolean )
current : 현재 객체
ex)
<!--첫번째 : 순수값, 두번째 : 숫자-->
<tr th:each="user, userStat : ${users}">
<td th:text="${userStat.count}">username</td>
<td th:text="${user.username}">username</td>
<td th:text="${user.age}">0</td>
<td>
index(0부터 시작) = <span th:text="${userStat.index}"></span><br/>
count(1부터 시작) = <span th:text="${userStat.count}"></span><br/>
size = <span th:text="${userStat.size}"></span><br/>
<!--홀짝여부, boolean-->
even? = <span th:text="${userStat.even}"></span><br/>
odd? = <span th:text="${userStat.odd}"></span><br/>
<!--첫번째 값인지-->
first? = <span th:text="${userStat.first}"></span><br/>
last? = <span th:text="${userStat.last}"></span><br/>
<!--현재 객체-->
current = <span th:text="${userStat.current}"></span>
</td>
</tr>
'◆Thymeleaf(타임리프) > 기초' 카테고리의 다른 글
[Thymeleaf] block (0) | 2023.02.07 |
---|---|
[Thymeleaf] 주석 (0) | 2023.02.07 |
[Thymeleaf] 속성 설정(th:*로 지정한 속성으로 값 대체) (0) | 2023.02.07 |
비교연산(html 엔티티) (0) | 2023.02.07 |
[Thymeleaf] 라디오버튼 + 데이터(Enum)으로 보내기 (0) | 2023.02.04 |