Thymeleaf 문법의 기본적인 특징 : html 태그 안에 th 문법을 추가하는 형태

 

<태그 th:속성="표현식 및 서버로부터 받는 값"/>

 

th:text="${}"

 

th:href="@{}"

 

th:with="${}"

 

th:value="${}"

 

th:action="@{}"

 

th:object="${}"

 

th:field="*{}"

 

th:if="${}", th:unless="${}"

 

th:each="변수 : ${list}"

 

th:switch, th:case

 

<사용 예>

<script th:inline="javascript">
	/*<![CDATA[*/
	function fnThymeleafExample() {
		var thymeleafVar1 = /*[[${exampleVo.exampleVal1}]]*/;
		var thymeleafVar2 = /*[[${exampleVal2}]]*/;
	}
	/*]]>*/
</script>

<td th:text="${exampleVo.exampleVal1}"> </td>
<td th:text="${#numbers.formatInteger(exampleVal2, 0, 'COMMA')}"> </td>

<form id="exampleForm" th:object="${exampleForm}" th:method="POST">
	<input type="hidden" th:field="*{exampleVal3}" />
	<div th:if="${exampleDto.example1.example2 != '1' && exampleDto.example1.example2 != '2'}">
		<label class="text-danger"> * 예제 </label>
		<input type="text" th:field="*{exampleVal4}" th:maxlength="${exampleDto.example2}" class="form-control">
		<p> 최대길이 [[${exampleDto.example2}]]자 </p>
		<p class="text-linebreak" th:utext="${exampleDto.example3}"> 예제 </p>
	</div>
</form>

+ Recent posts