3. View 환경설정
1. main > resources > static > index.html 파일 생성
2. 작성 후 서버 Restart
- 스프링 부트가 제공하는 Welcome Page 기능
. static/index.html 을 올려두면 Welcome page 기능을 제공한다.

thymeleaf 템플릿 엔진
- thymeleaf 공식 사이트: https://www.thymeleaf.org/
- 스프링 공식 튜토리얼: https://spring.io/guides/gs/serving-web-content/
- 스프링부트 메뉴얼: https://docs.spring.io/spring-boot/docs/current/reference/html/web.html#web.servlet.spring-mvc.template-engines
Programming
1. Controller 생성

- @Controller
- @GetMapping
- addAttribute
- return : View 이름
. 컨트롤러에서 리턴 값으로 문자를 반환하면 뷰 리졸버( viewResolver )가 화면을 찾아서 처리한다.
. 스프링 부트 템플릿엔진 기본 viewName 매핑
resources:templates/ +{ViewName}+ .html
2. View (html) 생성
- Controller에서 리턴한 데이터 값 가져오기
참고: spring-boot-devtools 라이브러리를 추가하면, html 파일을 컴파일만 해주면 서버 재시작 없이 View 파일 변경이 가능하다.
IntelliJ 컴파일 방법 : 메뉴 build → Recompile
728x90
728x90
'Spring > 스프링 입문 - 코드로 배우는 스프링 부트, 웹 MV' 카테고리의 다른 글
3. 스프링 웹 개발 기초 (0) | 2022.03.07 |
---|---|
2. 프로젝트 환경 설정 - Build 실행하기 (0) | 2022.03.06 |
2. 프로젝트 환경 설정 - 라이브러리 살펴보기 (1) | 2022.03.06 |
2. 프로젝트 환경 설정 - 프로젝트 생성 (0) | 2022.03.04 |
1. 강의 소개 (1) | 2022.03.04 |