此处是接收前台数据
前台JSP:
userName" value="${user.userName}"/>
enity(model)层:
public class User{
省略其他属性......
private string userNmae;
public string setUserName(string userName){
this.userName=UserName;
}
public string getUserName(){
return userNmae;
}
}
control层:
public ModelAndView XXX(@ModelAttribute User user,HttpServletRequest req, HttpServletResponse resp) {//@ModelAttribute("user"),不写默认类名首字母小写
User u=new User();
u.userName=user.getUserName();//前台input中name的名字应该和model中类的属性值对应,不是value中的值,否则此处取不到,为null
}