Gradle 프로젝트에서는 .jsp 파일이 아닌 .html 으로 생성합니다.
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<a href="/hello">hello</a>
</body>
</html>
@Controller
public class HelloController {
@GetMapping("hello")
public String hello(Model model) {
model.addAttribute("data", "hello!!");
return "hello";
}
}
<!DOCTYPE html>
<html>
<html xmlns:th="http://www.thymeleaf.org">
<title>Hello</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p th:text="'안녕하세요, ' + ${data}">안녕하세요. 손님</p>
</body>
</html>
<※ 결과는 다음과 같습니다.>
일반적인 SpringFramework와 사용방식이나 개념적인 면에서 차이를 보이는 것은 없습니다.전통적으로 수행하던 데이터를 받아 저장하고 View와 Controller에 저장된 데이터를 주고받도록 하는 역할을 똑같이 수행하게 됩니다.