Thymeleaf에서 자주 사용되는 문법

URL 관련

<a href="about.html">About Us</a>

서버에서 받아온 값을 전달하는 URL

<?php
// 서버에서 동적으로 받아온 값을 변수에 할당
$dynamicValue = "123";

// 해당 변수를 URL에 추가하여 링크 생성
echo "<a href='page.php?id=$dynamicValue'>Go to Dynamic Page</a>";
?>

If, Else, For 문

// if
th:if = "${size} == '0' " 
th:unless = "${size} == '0' "

// for
th:each="obj : ${list}"

사용 예제

<tbody id="docsTr">
     <tr th:if="${size} == '0'">
		<td colspan=2> No data! </td>
	 </tr>
     <tr th:unless="${size} == '0'" th:each="user : ${list}">
		 <td th:text="${user.index}"> 1 </td>
		 <td th:text="${user.name}"> Data Exist </td>
	</tr>
</tbody>

th:data 다음에 아무 이름이나 넣어줘도 됨