- [spring boot 2.1.7] profile 및 logback 설정 - [spring boot 2.1.7] thymelef 설정 - [spring boot 2.1.7] mybatis - mysql 5.7 연동 - [spring boot 2.1.7] hibernate - mysql 5.7 연동 설정
|
소스 : https://github.com/yamoe/spring-boot-example/tree/master/04.thymelef/arti
* thymelef 설정
- build.gradle 추가
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
- application-dev.yml 추가 (캐시 미사용)
spring:
thymeleaf:
cache: false
- application-alpha.yml, application-prod.yml 추가 (캐시 사용)
spring:
thymeleaf:
cache: true
- html 작성
<src/main/resources/templates/thymeleaf-page.html>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>page</title>
</head>
<body>
<h1>thymeleaf</h1>
<span th:text="${fruit}"></span>
</body>
</html>
- controller 작성
<ThymeleafController.java>
package com.example.arti.jsp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
@RequestMapping(value = "th")
public class ThymeleafController {
@RequestMapping("/page")
public ModelAndView mav() throws Exception{
// page 이름
ModelAndView mv = new ModelAndView("thymeleaf-page");
// 변수,값 설정
mv.addObject("fruit", "Pineapple");
return mv;
}
}
- 실행
'Java' 카테고리의 다른 글
[pinpoint 1.8.4] 설치 준비 - tomcat 9.0.24 (1) | 2019.09.01 |
---|---|
[pinpoint 1.8.4] 설치 준비 - hbase 1.2.7 standalone (0) | 2019.09.01 |
[spring boot 2.1.7] hibernate - mysql 5.7 연동 설정 (0) | 2019.08.30 |
[spring boot 2.1.7] mybatis - mysql 5.7 연동 (0) | 2019.08.29 |
[spring boot 2.1.7] JSP 설정 (0) | 2019.08.29 |
[spring boot 2.1.7] profile 및 logback 설정 (0) | 2019.08.29 |
[spring boot 2.1.7] 개발 준비 (0) | 2019.08.29 |
OpenJDK 설치 (0) | 2019.08.08 |