C. Ross
C. Ross

Reputation: 31848

How should I map model beans to view model beans in Spring MVC?

In my Spring MVC application we have form objects that are mapped to by the <form:form tag in JSP. These objects are separate from my regular model beans, and really form a sort of view model. The difficulty with these objects is the mapping between these objects and the actual model beans expected by the service objects. Currently we have manually written code mapping forms to beans and vice versa in the controllers. This is less than optimal because of the amount of extra code it requires. The other options we've considered are.

What is the best method for the long term health of the project of performing this action?

Upvotes: 4

Views: 936

Answers (1)

ayengin
ayengin

Reputation: 1596

I suggest you to use dozer framework for mapping domain objects and view object to each others .Only problem you will have to still create view class manually.You can also automate this with code generation.

Upvotes: 1

Related Questions