1. Notes modifying parameters, pay attention to the point, although not where the user object is added to the model, but springmvc will be automatically added to it, key for the class name in lowercase, value for the current object
@RequestMapping("/testModelAttr")
public String testModelAttr(User user,Model model){
System.out.println(model);
return "/result";
}
You can specify key value added @ModelAttribute
When 2. @ modelAttribute modification method, when it is placed on the method no matter what request will first call the method
Note: This method also has model, model if in this method of accessing a key1, when you call on the request method into the model in key2, when the key1 == key2 not real time, key2 will cover key1, pay attention here but to cover the key value corresponding to replace
@ModelAttribute
public void test2(){
System.out.println("来到了ModelAttribute");
}