본문 바로가기

카테고리 없음

Thymeleaf map

<table th:each="entry : ${thing.attributes}">
    <tr>
        <td th:text="${entry.key}">Key 1</td>
        <td th:text="${entry.value}">Value 1</td>
    </tr>
</table>

Map의 key, value를 활용하는 반복문

<div th:if="not ${thing.attributes.isEmpty()}">
    //Map이 비어있지 않을 때 실행할 내용
</div>

Map에 내용이 있을때만 실행하는 분기문

 

Reference:

http://stackoverflow.com/questions/23144358/how-to-loop-through-map-in-thymeleaf