Reputation: 3424
I am moving forward from Struts2 controllers to Spring MVC 2.5
In case of Struts2 OGNL used to take care of populating the property of Action class. Here in Spring MVC 2.5 also they have a SimpleFormController
which can call the setCommandClass(UserDefinedBean.class)
in the constructor to auto-populate property of the bean class from parameters.
But in case of MultiActionController
(this seems very useful for my requirement) I am doing request.getParameter("paramName");
to get parameters from request. Is there any way to utilize the setCommandClass()
with MultiActionController
?
Upvotes: 0
Views: 2128
Reputation: 818
You can have the command object as one of the argument in your action method, eg:
public (ModelAndView | Map | String | void) actionName(HttpServletRequest request, HttpServletResponse response, Object commandObject);
For extensive use of data binding you can always override the initBinder(...) method to have your custom binding and validators.
Between why using Spring 2.5.x ? Why not Spring 3.0.x ? You have more flexibility in the new version by using annotations. Even Spring doesn't recommend using the old method of extending Controllers. Just a suggestion as I am not sure about your design or requirement.
Upvotes: 3