Web/Front
[HTML] Thymeleaf
yj_oo_
2021. 7. 27. 15:37
Thymeleaf
- "웹(Servlet)환경과 웹이 아닌 환경 모두애서 작동할 수 있는 Java XML/XHTML/HTML5 template engine"
- spring MVC구조에서 View 담당
- src/main/resources/templates 경로를 기본 경로로 인식(의존성 추가하면)
간단한 사용법
Maven Dependencies 추가(pom.xml)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
application.yml에 추가
<!--application.yml-->
thymeleaf:
prefix: classpath:templates/
suffix: .html
cache: true
<!--application-local.yml-->
thymeleaf:
cache: false
.html에 추가해서 사용
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Thymeleaf Test</title>
</head>
<body>
<p th:text="'타임리프 테스트 '" />
</body>
</html>