<form role="form" action="/success" method="post">
账号:<input type="text" id="id" name="id"> <br>
密码:<input type="password" id="password" name="password"> <br>
<input type="submit" id="login" value="login">
</form>
<a href="/success">AllMovies</a>
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>success</title>
</head>
<body>
<h1>登录成功!</h1>
<table>
<tr>
<th>name</th>
<th>director</th>
<th>genres</th>
<th>country</th>
</tr>
<tr th:each="movieInfo : ${list}">
<td th:text="${movieInfo.title}"></td>
<td th:text="${movieInfo.director_name}"></td>
<td th:text="${movieInfo.genres}"></td>
<td th:text="${movieInfo.coutry}"></td>
</tr>
</table>
</body>
</html>
@RequestMapping(value = "/success", method = RequestMethod.POST)
public String login(int id, String password) {
User user = userService.loginIn(id, password);
if (user != null) {
return "success";
} else {
return "login";
}
}
@RequestMapping("/success")
public String index(ModelMap map) {
List<MovieInfo> list = movieInfoService.getAllMovies();
map.addAttribute("list", list);
return "success";
}
点击form里的提交按钮
点击超链接
如果想在点击form的提交按钮后加载内容该怎么办