728x90
MVC : Model, View, Controller
Controller
@Controller
public class HelloController {
@GetMapping("hello-mvc")
public String helloMvc(@RequestParam("name") String name, Model model) {
model.addAttribute("name", name);
return "hello-template";
}
}
View
resources/templates/hello-template.html
<html xmlns:th="http://www.thymeleaf.org">
<body>
<p th:text="'hello ' + ${name}">hello! empty</p>
</body>
</html>
실행 : http://localhost:8080/hello-mvc?name=spring
MVC, 템플릿 엔진 이미지
'Spring > 스프링 입문' 카테고리의 다른 글
[Spring] 3. 회원 관리 예제 (1) | 2023.10.31 |
---|---|
[Spring] 2-3. API (1) | 2023.10.31 |
[Spring] 2-1. 정적 컨텐츠 (0) | 2023.10.31 |
[Spring] 1-4. 빌드하고 실행하기 (0) | 2023.10.30 |
[Spring] 1-3. View 환경설정 (0) | 2023.10.30 |