SPING/Spring 정리

[Spring] Thymeleaf 사용하기 application.properties 설정

h0-0cat 2023. 6. 25. 17:55
728x90

Thymeleaf 사용하기 

application.properties 설정

 

server.port=

# 서버포트 변경
server.port=8080
선언하지 않으면 8080이 기본

 


spring.thymeleaf.suffix=

# 템플릿 확장자 지정
spring.thymeleaf.suffix=.html

html을 사용할거면 .html로 설정

만일 jsp를 사용한다면 .jsp를 입력해주면 된다.

 

 


 

 spring.thymeleaf.prefix=

# 템플릿파일의 위치 지정 (뒤에 공백이 있으면 않됨)
spring.thymeleaf.prefix=classpath:templates/

 

경로를 잡아준다.

resources 폴더 밑 templates 폴더가 보이고 그 밑으로 html 파일이 있는 것을 확인할 수 있다.

 

 


spring.thymeleaf.cache=

# 캐시 사용 않함
spring.thymeleaf.cache=false

thymeleaf에 대한 캐시를 남기지 않는다.

cache=false 설정(운영시는 true)

 


 

 

스프링부트 기본 에러 페이지 변경하기

server.error.whitelabel.enabled=false

기본에러페이지가 아닌 템플릿의 에러페이지가 실행된다.

 

 

templates/ error.html  

에러페이지를 만들어서 쓸수 있다.

 

 

 

 

728x90