
서버측에서 클라이언트가 보게될 웹 페이지를 동적으로 만드는 역할<html xmlns:th="http://www.thymeleaf.org">
<div th:text="${data}"></div>
<div>숫자: <span th:text="${num}"></span></div>
th:object 속성 값을 사용한다.<h3>복합 데이터(객체, 맵) 프로퍼티</h3>
<!-- 변수 표현식 -->
<div>이름 : <span th:text="${dto.getName()}"></span></div>
<div>이름 : <span th:text="${dto.name}"></span></div>
<div>나이 : <span th:text="${dto.age}"></span></div>
<div>주소 : <span th:text="${dto.address}"></span></div>
<!-- 선택 변수 표현식 -->
<div th:object="${dto}">
<div>이름 : <span th:text="*{name}"></span></div>
<div>나이 : <span th:text="*{age}"></span></div>
<div>주소 : <span th:text="*{address}"></span></div>
</div>
<h3 th:text="#{item.title}"></h3>
<a th:href="@{/m8(seq=${seq})}">링크입니다.</a>
<a href="/m8?seq=100&mode=add">링크입니다.</a>
<a th:href="@{/m8(seq=${seq}, mode=${mode})}">링크입니다.</a>
해당 태그가 사라지고 대신 조각 페이지를 출력한다.📎 th:include="템플릿명 :: 조각이름"
[ex] 특정 영역을 가져오는 방법 1
<!-- sub2.html -->
<div th:fragment="title">제목입니다.</div>
위 sub2.html에 th:fragment 속성에 title라는 값이 보여진다.
다른 페이지에서 위의 fragment="title" 부분을 insert하는 예제이다.
<!-- m14.html -->
<div th:insert="~{inc/sub2.html :: title}"></div>
th:insert="~{템플릿명 :: 조각이름}"의 형태로 가져올 수 있다.
[ex] 특정 영역을 가져오는 방법 2
<!-- sub2.html -->
<div th:fragment="title">제목입니다.</div>
<div th:fragment="content">내용입니다.</div>
<div th:fragment="owner(name,tel)">
소유주: <span th:text="${name}"></span>,
연락처: <span th:text="${tel}"></span>
</div>
<!-- m14.html -->
<div th:insert="~{inc/sub2.html :: title}"></div>
<div th:insert="~{inc/sub2::content}"></div>
<div th:insert="~{inc/sub2::owner('아무개', '010-1234-5678')}"></div>
<div th:insert="~{inc/sub2::owner('테스트', '010-8547-8523')}"></div>
<!-- application.properties -->
# template 경로 접미사
spring.thymeleaf.suffix=.html

[ex] insert vs replace
<!-- sub1.html -->
조각 페이지 1
<!-- m14.html -->
<h3>insert</h3>
<div th:insert="~{inc/sub1.html}"></div>
<h3>replace</h3>
<div th:replace="~{inc/sub1.html}"></div>
