타임리프 사용

 

 

튜토리얼 : 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

 

스프링 부트 thymeleaf viewName 매핑

  • resources:templates/ +{ViewName}+ .html

 

controller

@Controller
public class HelloController {

    @GetMapping("hello")
    public String hello(Model model) {
    	model.addAttribute("data", "hello!!");
    	return "hello";
    }
}

 

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>

 

 

코드를 수정할 때마다 재시작 해야하는 불편함이 있다. 

-> devtools 라이브러리 사용

 

build.gradle에 추가

implementation 'org.springframework.boot:spring-boot-devtools'

build - Recompile {파일명}   <- 변경한 파일만 다시 컴파일하여 프로잭트 재시작 없이 변경 반영

'프로그래밍 > SpringBoot & JPA Use1' 카테고리의 다른 글

casecade  (0) 2022.06.19
엔티티 설계시 주의점  (0) 2022.06.19
엔티티 클래스 개발  (0) 2022.06.19
도메인 분석 설계  (0) 2022.06.19
JPA와 DB 설정, 동작확인  (0) 2022.06.19

+ Recent posts