[SpringBoot] Spring 프로젝트에서 Thymeleaf 설정하는 방법 + CSS도...

[SpringBoot] Spring 프로젝트에서 Thymeleaf 설정하는 방법 + CSS도...

먼저, thymeleaf를 설정하는 방법을 소개 한 후,

thymeleaf 설정 후 css도 설정하는 방법을 알려드리겠습니다.

Thymeleaf 설정하는 방법

STEP 1. build/gradle 파일 설정

아래와 같이 thymeleaf 관련 dependency를 추가합니다.

.. dependencies { .. implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect') }

STEP 2. application.properties 설정

아래의 4줄을 추가합니다.

spring.thymeleaf.cache=false spring.thymeleaf.check-template-location=true spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html

STEP 3. html 파일 상단에 thymeleaf 관련 태그 추가

아래의 첫줄인

....

CSS 설정하는 방법

STEP 1. src/main/resources/ 폴더에 static 폴더를 추가합니다.

(src/main/resources/static)

예를들어 style.css를 추가했다고 가정해보겠습니다.

STEP 2. html파일에 CSS 추가

아래의 태그를 참고하여,

style.css 파일과 연동하게 만듭니다.

...

적용된걸 확인할 수 있습니다!

조금이라도 도움이 되셨으면 아래의 하트 한번 눌러주시면 감사하겠습니다!!

from http://i5i5.tistory.com/636 by ccl(A) rewrite - 2021-12-02 01:01:48