I have noticed in many tutorials and other places that a default model attribute named "SpringWeb" is used to map all jsp elements to a java POJO when the form is submitted.
For example, in the following tutorial, @ModelAttribute("SpringWeb")
is mapped to the Student object.
@RequestMapping(value = "/addStudent", method = RequestMethod.POST)
public String addStudent(@ModelAttribute("SpringWeb")Student student,
ModelMap model) {
model.addAttribute("name", student.getName());
model.addAttribute("age", student.getAge());
model.addAttribute("id", student.getId());
return "result";
}
@RequestMapping(value = "/student", method = RequestMethod.GET)
public ModelAndView student() {
return new ModelAndView("student", "command", new Student());
}
http://www.tutorialspoint.com/spring/spring_mvc_form_handling_example.htm
Even if a "new ModelAndView("student", "command", new Student())
" object is not returned by the GET method as in the example, the "SpringWeb" model attribute is still present when form is posted back.
For example - in the GET request if I write model.addAttribute ("xyz", "123)
and just return the view name and I don't map the form fields using "path" in jsp tags. The form fields will still map to the java object via "SpringWeb" when the form is posted back.
There are no search results for "SpringWeb" in github too: https://github.com/spring-projects/spring-framework/search?utf8=%E2%9C%93&q=SpringWeb&type=
I do understand that custom model attributes can be used and mapped to the form elements instead of using @ModelAttribute("SpringWeb")
.
But, I could not find any related questions in stackoverflow which could explain in detail about what "SpringWeb" is and whether it is a good or bad practice to use it?
I debugged the model object on a "POST" request and found that "SpringWeb" was present as a "key" and "value" pair automatically in the "BindingAwareModelMap" model object. But, I could not find any documentation related to "SpringWeb" in the below link.
What is "SpringWeb"? My current understanding is that it is a "catch-all" model attribute which is mapped by spring automatically when form is submitted. If yes, then how was it discovered and decided to use it without any documentation? (at least I could not find any)