Spring
Spring ) thymeleaf 기능 알아보기
Albosa2lol
2023. 6. 14. 17:25
build.grade 의 dependencies 에서
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
thymeleaf 를 설정할 경우
templates 에 있는 (html 파일)을 반환해준다.
@GetMapping("/html/templates")
public String htmlTemplates() {
return "hello";
}
templates 엔 hello.html 이 있는 상태,
이런식으로 Controller 에서 html 의 이름만 입력하면 된다.