package hello.hellospring.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!!!");
return "hello";
}
}
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<hed>
<title>hello</title>
<meta http-equiv="Content-Type" content="text/html"; charset="UTF-8"/>
</hed>
<body>
<p th:text="'안녕하세요. '+ ${data}">안녕하세요. 손님!</p>
</body>
</html>
Controller에서 return 값으로 문자를 반환하면 viewResolver가 화면을 찾아서 처리
스프링부트 템플릿엔진 기본 viewName 매핑 'resources:templates/' + [ViewName] + '.html'