3.2.2 제어문 처리
타임리프의 제어문 처리
- th:if ~ unless
- 삼항 연산자 스타일
th:if ~ unless
<li th:each = "dto, state : ${list}">
<span th:if="${dto.sno % 5 == 0}" th:text="${'----------------'+dto.sno}"></span>
<span th:unless="${dto.sno % 5== 0}" th:text="${dto.first}"></span>
</li>
실행 결과
삼항 연산자를 사용하는 방법
<ul>
<li th:each = "dto, state : ${list}" th:text="${dto.sno % 5 == 0}?${dto.sno}">
</li>
</ul>
실행 결과
응용
728x90
'🏰 Back-end > Spring Boot' 카테고리의 다른 글
[Spring Boot] 링크 처리 (0) | 2021.07.18 |
---|---|
[Spring Boot] inline 속성 (0) | 2021.07.18 |
[Spring Boot] 반복문의 상태 객체 (0) | 2021.07.15 |
[Spring Boot] Thymeleaf의 기본 사용법 (0) | 2021.07.14 |
[Spring Boot] 스프링 MVC와 Thymeleaf | 포트 번호 바꾸기 | 404 에러 해결 (0) | 2021.07.11 |
댓글