티스토리 뷰

WEB/기타

[Thymeleaf] 2. Thymeleaf 사용 설정

silverline79 2024. 1. 19. 22:00

2. Thymeleaf 사용 설정

2-1 Maven dependencies 추가 ( pom.xml )

spring-boot-starter-thymeleaf
thymeleaf 뷰 템플릿 엔진을 사용하기 위한 기본적인 라이브러리
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
thymeleaft-layout-dialect
thymeleaf를 이용해서 layout을 만들기 위해 추가적으로 사용되는 라이브러리
header, contents, footer 등으로 나누고 headerfooter는 고정한 뒤 contents 영역만 바꿔가면서 렌더링을 가능하게 해줌
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>

 

2-2 application.yml 선언

spring:
thymeleaf:
mode: HTML
encoding: UTF-8
check-template-location: true
prefix: classpath:/templates/
suffix: .html
cache: false
mode 사용할 타임리프 TemplateMode, 기본값 HTML
encoding 템플릿의 인코딩, 기본값 UTF-8
check-template-location 템플릿 위치 존재 확인, 기본값 true
prefix ViewResolver의 접두어, 기본값은 classpath:/templates/
suffix ViewResolver의 접미어, 기본값 .html
html 확장자 지정해, 컨트롤러에서 타임리프 뷰를 호출할 때,
확장자를 붙이지 않아도 인식하도록 함.
cash 서버 내부 캐시
true : 타임리프 프로젝트를 매번 다시 시작해야함
false : 새로고침만으로 반영됨

 

'WEB > 기타' 카테고리의 다른 글

[Thymeleaf] 4. Thymeleaf 템플릿 만들기  (0) 2024.01.19
[Thymeleaf] 3. Thymeleaf 기본문법  (0) 2024.01.19
[Thymeleaf] 1. Thymeleaf 란?  (0) 2024.01.19
[SQL] TABLE 생성  (0) 2024.01.19
[SQL] DB 생성 구문  (0) 2024.01.19
댓글