我正在學習使用thymeleaf模板來完成一個項目,我似乎正在完成並似乎缺少了一些東西。在Thymleaf和Spring啓動時訪問模型屬性
我試圖創建一個非常簡單的Hello類型的應用程序,這裏是我的代碼(注意,我用的常規):
控制器:
@Controller
class TestController {
@RequestMapping("/")
String homePage(@RequestParam("name") String name, ModelAndView modelAndView){
modelAndView.addObject("name", name)
return "home"
}
}
home.html的:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<h1>Hello</h1>
<p th:text="${name}" />
</body>
</html>
我錯過了什麼?我只是得到「你好」,沒有別的,當我打:
http://localhost:8080/app-0.0.1-SNAPSHOT/?name=Sam