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";
}
}
View
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<p th:text="'hello ' + ${name}">hello! empty</p>
</body>
</html>
localhost:8080/hello-mvc
--> whitelabel error page
※ 파라미터 name 값을 입력하지 않아서 발생하는 에러
localhost:8080/hello-mvc?name=spring
입력하면 정상적으로 spring이 출력이 된다.