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


image.png