开发者

what do the terms formBackingObject and ModelAttribute mean in Spring MVC?

I guess I don't understand the difference between a "FormBackingObject" and a "ModelAttribute" in 开发者_C百科spring MVC.

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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜