提交的表单:
<form action="abc" method="post">
姓名<input type="text" name="username" ><br>
密码<input type="text" name="password" ><br>
手机号<input type="text" name="phone" ><br>
<button type="submit">点击测试</button>
</form>
接收controller
public ModelAndView itemList(User user){
System.out.println(user);
ModelAndView ma=new ModelAndView();
ma.setViewName("/hello.jsp");
return ma;
}
pojo
public class User {
private String username;
private String password;
private String phone;
。。。。省略getter/setter方法
页面传过来的参数的名字,跟User的成员变量保持一致。
这样就能将参数值,自动映射到user对象的属性上。