Spring
Thymeleaf (타임리프)
yong_ღ'ᴗ'ღ
2022. 12. 10. 01:33
◼ Thymeleaf (타임리프)
<!--thymeleaf 템플릿 엔진 선언-->
<!--이거 쓰면, 템플릿 엔진으로 thymeleaf 문법 사용할 수 있음-->
<html xmlns:th="http://www.thymeleaf.org">
타임리프 장점: 서버돌리지 않고 그냥 열어도 hello! empty 라는 메세지 볼 수 있다.
템플릿 엔진으로써 동작을 하면 text=" " 안에 있는 내용으로 치환되어 보여진다.
<html xmlns:th="http://www.thymeleaf.org">
<body>
<p th:text="'hello ' + ${name}">hello! empty</p>
</body>
</html>
✔ 반복문 → th:each="변수 : 컬렉션"
<tr th:each="member : ${members}">
<td th:text="${member.id}"></td>
<td th:text="${member.name}"></td>
</tr>