티스토리 뷰

TIL

자주 사용하는 Thymeleaf 문법

해미깨미 2021. 2. 2. 23:52

th:each

<div th:each="item,index : ${itemList}">
<div th:if="${item.exists()}">
</div>
<div th:if="${index.index} > 0">
</div>
</div>

th:block

<th:block></th:block>

th:if

<!-- 여러 조건문 -->
<div th:if="${BooleanValue}"></div>
<div th:if="${BooleanValue}"></div>
<!-- unless는 if문의 조건식과 같아야함 -->
<div th:if="${BooleanValue}"></div>
<div th:unless="${BooleanValue}"></div>

th:text

<div th:text="'Example'"></div>
<div th:text="${Example}"></div>

th:src

<img th:src="@{/img/ranked-emblems/Emblem_{var}.png(var = ${})}">

th:with

<!-- Static 메소드는 T() 이렇게 사용 가능 -->
<div th:with="dayDiff = ${new org.joda.time.Interval(
matches.getCreationTime().toInstant(), T(org.joda.time.Instant).now()
).toDuration().getStandardDays()}"
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/04   »
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
글 보관함