먼저, 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')
}Copy
STEP 2. application.properties 설정
아래의 4줄을 추가합니다.
spring.thymeleaf.cache=false
spring.thymeleaf.check-template-location=true
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.htmlCopy
STEP 3. html 파일 상단에 thymeleaf 관련 태그 추가
아래의 첫줄인 <html xmlns.. 로 시작하는 것을 추가합니다.
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
....Copy
CSS 설정하는 방법
STEP 1. src/main/resources/ 폴더에 static 폴더를 추가합니다.
(src/main/resources/static)
예를들어 style.css를 추가했다고 가정해보겠습니다.
STEP 2. html파일에 CSS 추가
아래의 <link> 태그를 참고하여,
style.css 파일과 연동하게 만듭니다.
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css" type="text/css">
<title></title>
...
728x90
'Programming > Web-Spring' 카테고리의 다른 글
[SpringBoot] @ModelAttribute 값받을때 null값 나오는 현상 (0) | 2023.06.14 |
---|---|
[Thymeleaf] SpringBoot에 Thymeleaf 적용하기 (0) | 2023.06.14 |
[intellij/spring] h2 (메모리영역에서 사용하는db)설정 방법 (0) | 2022.05.27 |
[intellij] spring 프로젝트 생성 및 시작 (0) | 2022.05.23 |
SpringFramework 에서 다국어처리지원하기 (0) | 2018.08.08 |