我想处理简单的表格。这是来自我的signUp.jsp的表格,我收到了我的数据
<form:form method="POST" commandName="user-entity" action="process.html">
<table>
<tr>
<td><form:label path="userName">Name:</form:label></td>
<td><form:input path="userName" /></td>
</tr>
<tr>
<td><form:label path="label">Age:</form:label></td>
<td><form:label path="label"/></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit"/>
</td>
<td></td>
<td></td>
</tr>
</table>
</form:form>
我的result.jsp
的一部分<p>User's name is ${user.userName}. The age is ${user.age}.</p>
和UserController.java
@Controller
public class UserController {
@RequestMapping(value = "/signUp")
public ModelAndView signUpPage() {
return new ModelAndView("signUp", "user-entity", new User());
}
@RequestMapping(value = "/process")
public ModelAndView processUser(@ModelAttribute User user) {
ModelAndView model = new ModelAndView();
model.setViewName("result");
model.addObject("user", user);
return model;
}
}
结果我得到了
User's name is ${user.userName}. The age is ${user.password}.
我不知道为什么。哪里可能是问题?