티스토리 뷰
1. Thymeleaf 설정 (view)

resources/static : 템플릿 엔진이 포함되지 않은 html 리소스 파일
resources/templates : thymeleaf 파일
1) hello.html
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<p th:text="'안녕하세요. ' + ${data}" >영양분</p>
</body>
</html>
2) HelloController.java
package mandykr.nutrient.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class HelloController {
@GetMapping("hello")
public String hello(Model model) {
model.addAttribute("data", "hello nutrient!!");
return "hello";
}
}
2. spring-boot-devtools 라이브러리 추가
html 파일을 수정하면 서버를 재시작 하지 않아도
컴파일 만으로 내용이 반영되도록 설정.
build.gradle > dependencies
//implementation 'org.springframework.boot:spring-boot-devtools'
// 위의 코드로 반영되지 않아 다음 코드로 작성
runtimeOnly 'org.springframework.boot:spring-boot-devtools'
파일수정 > build > recompile > refresh

출처
https://www.inflearn.com/course/스프링부트-JPA-활용-1 실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발(김영한)
728x90
'Spring Boot > 환경설정' 카테고리의 다른 글
| [Spring Boot#환경설정] 6. Querydsl 설정 (0) | 2021.11.24 |
|---|---|
| [Spring Boot#환경설정] 5. Spring Data JPA로 변경 (0) | 2021.11.24 |
| [Spring Boot#환경설정] 4. JPA 설정 (0) | 2021.11.23 |
| [Spring Boot#환경설정] 2. Spring boot 프로젝트 생성 (0) | 2021.11.23 |
| [Spring Boot#환경설정] 1. H2 데이터베이스 설치 (0) | 2021.11.23 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- H2
- Git
- Spring
- kafka
- HTTP 헤더
- Spring Boot
- Ubiquitous Language
- Stream
- 스프링 카프카 컨슈머
- clean code
- 계층형 아키텍처
- 스프링 예외 추상화
- java8
- MySQL
- ATDD
- spring rest docs
- mockito
- 마이크로서비스 패턴
- 육각형 아키텍처
- 클린코드
- 이벤트 스토밍
- named query
- TDD
- http
- 도메인 모델링
- 폴링 발행기 패턴
- 학습 테스트
- 트랜잭셔널 아웃박스 패턴
- Spring Data JPA
- JPA
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
글 보관함
