M odel
V iew
C ontroller
package hello.hellospring.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@Controller
public class HelloController {
@GetMapping("hello-mvc")
public String helloMvc(@RequestParam("name") String name, Model model) {
model.addAttribute("name", name);
return "hello-template";
}
}
@RequestParam(”name”)
사용자가 웹 페이지를 통해 입력한 값(?name=John)을 서버로 전달받아 메소드에서 활용할 때 사용하는 도구
<html xmlns:th="<http://www.thymeleaf.org>">
<body>
<p th:text = "'hello ' + ${name}">hello! empty</p>
</body>
</html>