<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns="">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<style>
.odd-row{
background-color: darkgoldenrod;
}
</style>
<body>
<h1>if, unless</h1>
<table border="1">
<tr>
<th>count</th>
<th>username</th>
<th>age</th>
</tr>
<tr th:each="user, userStat : ${users}">
<td th:text="${userStat.count}">1</td>
<td th:text="${user.username}">username</td>
<td>
<span th:text="${user.age}">0</span>
<span th:text="'미성년자'" th:if="${user.age < 20}"></span>
<span th:text="'미성년자'" th:unless="${user.age >= 20}"></span>
</td>
</tr>
</table>
<h1>switch</h1>
<table border="1">
<tr>
<th>count</th>
<th>username</th>
<th>age</th>
</tr>
<tr th:each="user, userStat : ${users}">
<td th:text="${userStat.count}">1</td>
<td th:text="${user.username}">username</td>
<td th:switch="${user.age}">
<span th:case="10">10살</span>
<span th:case="20">20살</span>
<span th:case="*">기타</span>
</td>
</tr>
</table>
<h1>th Map</h1>
<table border="1">
<tr>
<th>id</th>
<th>username</th>
<th>age</th>
</tr>
<tr th:each="user, userStat : ${userMap.entrySet()}" th:class="${userStat.odd} ? 'odd-row' : ''">
<td th:text="${user.key}"></td>
<td th:text="${user.value.username}"></td>
<td th:switch="${user.value.age}">
<span th:case="40">40대</span>
<span th:case="50">50대</span>
<span th:case="*">노인</span>
</td>
</tr>
</table>
</body>
</html>