SpringMVC Model,ModelMap ModelAndView
SpringMVC 调用方法之前会创一个隐含的模型对象(即Model,ModelMap ModelAndView)
//@ModelAttribute 先于login方法执行
@ModelAttribute
public void userModel(String username,String password,Model model){
User user = new User();
user.setUserName(username);
model.addAttribute("user", user );
}
@RequestMapping("/login")
public String login(Model model){
User user = (User) model.asMap().get("user");
System.out.println(user.getUserName());
return "successPage";
}