@Controller
public class MyController {
@RequestMapping(value = "/click")
public String registerForm(Model model) {
User user = new User("xiaom", "男", 28);
model.addAttribute("command", user);
return "result";
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form:form action="click" method="POST">
<table>
<tr>
<td>姓名:</td>
<td><form:input path="username" /></td>
</tr>
<tr>
<td>性别:</td>
<td><form:input path="sex" /></td>
</tr>
<tr>
<td>年龄:</td>
<td><form:input path="age" /></td>
</tr>
</table>
</form:form>
</body>
</html>