views:

466

answers:

1

I guess I don't understand the difference between a "FormBackingObject" and a "ModelAttribute" in spring MVC.

Seems like both gets initiated and populated by Spring with an incoming request.

+3  A: 

Good question. This comes down to a difference in terminology between Spring 2.0 MVC, which used a controller class hierarchy, and Spring 2.5 MVC, which uses annotations.

The "form backing object" is the object which the Spring 2.0-style AbstractFormController (and subclasses like SimpleFormController) would use to bind the form data on to.

@ModelAttribute does much the same thing for Spring 2.5-style annotated controllers, but in a less rigid way.

So you're right in that the two do pretty much the same thing, but the style is really quite different. Both are valid approaches, and both are supported in Spring 2.5 (and 3.0).

skaffman
thanks! that was a very helpful answer