Spring Web MVC and the creation of new beans

We are working on a Spring 3.0.5 web-based MVC application. In our code, we pretty often do something like this:

@ModelAttribute(ModelKeys.SOME_BEAN)
public SomeBean newSomeBean() {
  return new SomeBean();
}

I think this is not necessary. But if this is really not the case, then I wonder how it was possible to miss so many code reviews? In my understanding, if the controller method needs NEW SomeBean, should annotating the parameter in this method using @ModelAttribute be enough? Spring will use the default constructor to create the new required bean to call the controller method, for example:

@RequestMapping(method = RequestMethod.POST)
public String doIt(
  @ModelAttribute(ModelKeys.SOME_BEAN) final SomeBean bean,
  final BindingResult bindingResult)
{
  ...
}

Spring SomeBean POSTed, ? , ? , ? , , , , bean?

+3
1

@ModelAttribute bean HTTP. . , , , , . , , . // , .

+2

All Articles