Home > Backend > Spring > ๐Ÿƒ[Spring] MVC์™€ ํ…œํ”Œ๋ฆฟ ์—”์ง„.

๐Ÿƒ[Spring] MVC์™€ ํ…œํ”Œ๋ฆฟ ์—”์ง„.
Spring Framework

๐Ÿƒ[Spring] MVC์™€ ํ…œํ”Œ๋ฆฟ ์—”์ง„.

  • 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
<html xmlns:th="htt[://www.thymeleaf.org">
<body>
<p th:text="'hello ' + ${name}">hello! empty</p>
</body>
</html>
  • ์‹คํ–‰
    • http://localhost:8080/hello-mvc?name=spring

  • MVC ํ…œํ”Œ๋ฆฟ ์—”์ง„ ์ด๋ฏธ์ง€