반복문과 if 처리
'sno의 값이 5의 배수들만 출력하라'
<li th:each="dto : ${list}" th:if="${dto.sno % 5 ==0}">
[[${dto}]]
</li>
<ul>
<li th:each="dto:${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>
삼항연산자
'sno가 5로 나눈 나머지가 0인 경우에는 sno를 출력하라'
<ul>
<li th:each="dto : ${list}" th:text="${dto.sno % 5 == 0}?${dto.sno}"></li>
</ul>
'sno가 5로 나눈 나머지가 0인 경우에는 sno만을 출력하고 나머지는 first를 출력하라'
<ul>
<li th:each="dto : ${list}"
th:text="${dto.sno % 5 == 0}?${dto.sno}: ${dto.first}"></li>
</ul>
특정 상황에 CSS 클래스 지정하기
<style>
.target {
background-color: lightpink;
}
</style>
<ul>
<li th:each="dto : ${list}" th:class="${dto.sno % 5 ==0}?'target'"
th:text="${dto}"></li>
</ul>