:서버가 “있는 그대로” 파일을 브라우저에 보내주는 것
Model: 데이터를 담는 공간
View: 사용자에게 보이는 화면(HTML)
Controller: 요청 받고, 데이터(Model)에 담아서 View로 넘기는 역할
💡hello(): 내부에서 직접 값 넣기, 사용자 입력 필요 없음 즉, 고정된 값
<Controller>
@GetMapping("hello")
public String hello(Model model) {
model.addAttribute("data", "멋쟁이 사자처럼!");
return "hello"; // 여기 "hello"는 templates/hello.html 파일을 찾겠다는 뜻!
}
<View>
<!DOCTYPE html>
<html xmlns:th="<http://www.thymeleaf.org>">
<head>
<meta charset="UTF-8">
<title>Hello</title>
</head>
<body>
<p th:text="${data}">여기에 값이 들어갑니다</p>
</body>
</html>
💡hello-mvc() : 외부에서 값 가져오기 즉, 사용자 입력이 필요