실전! 스프링 부트와 JPA 활용1(웹 애플리케이션 개발)

Ch01. 프로젝트 환경설정 - View 환경 설정

webmaster 2022. 4. 24. 00:48
728x90

thymeleaf 공식 사이트: https://www.thymeleaf.org/

 

Thymeleaf

Integrations galore Eclipse, IntelliJ IDEA, Spring, Play, even the up-and-coming Model-View-Controller API for Java EE 8. Write Thymeleaf in your favourite tools, using your favourite web-development framework. Check out our Ecosystem to see more integrati

www.thymeleaf.org

  • 작성하지 않아도 볼 수 있다는 장점이 있다.

스프링 공식 튜토리얼: https://spring.io/guides/gs/serving-web-content/

 

Serving Web Content with Spring MVC

this guide is designed to get you productive as quickly as possible and using the latest Spring project releases and techniques as recommended by the Spring team

spring.io

스프링 부트 매뉴얼: https://docs.spring.io/spring-boot/docs/2.1.6.RELEASE/reference/html/boot-features-developing-web-applications.html#boot-features-spring-mvc-template-engines

 

29. Developing Web Applications

The Spring Web MVC framework (often referred to as simply “Spring MVC”) is a rich “model view controller” web framework. Spring MVC lets you create special @Controller or @RestController beans to handle incoming HTTP requests. Methods in your contr

docs.spring.io

Controller

HelloController

Hello.HTML

화면 Thymeleaf
출력 결과
스프링 부트 관례

  • 스프링 부트가 String을 리턴하여도 해당 관례 때문에 페이지를 출력해 주는 것이다.
  • Index 페이지 띄우기(정적 페이지)

정적 페이지

  • static/index.html 에 생성

참고

Spring-boot-devtools 라이브러리를 추가하면, HTML 파일을 재 컴파일만 해주면 서버 재시작 없이 View 파일 변경이 가능하다.( 메뉴 Build -> Recompile)

Build.gradle devtools 의존성 추가

  • HTML를 수정한 뒤 build에 -> recompile 'HTML 파일'을 눌러 해당 HTML만 수정하면 반영이 된다(서버를 안 꺼도 HTML 수정한 것이 반영이 된다.)
728x90