Expect to come across this popular question in Java Spring Interview Questions.  The @ModelAttribute annotation is one of the most important Spring - MVC annotations. The @ModelAttribute is an annotation that links a method parameter or method return value to the attribute named model and then exposes it to a web view. At the Method Level The purpose of this method is to add one or more model attributes when the annotation is used at the method level. Such methods support the same types of arguments as @RequestMapping, but cannot be mapped directly to requests. @RequestMapping(value = "/addUser", method = RequestMethod.POST)
public String submit(@ModelAttribute("user") User user) {
// Code that uses the user object
return "userView";
} It binds the data of the form to a bean. The controller annotated with @RequestMapping can be annotated with @ModelAttribute by custom class argument(s). This is commonly referred to as data binding in Spring - MVC, a common mechanism that saves you from individually analyzing each form field.