Is there a way to map a Spring 3.0 MVC @RequestParam directly to a Java Bean?

You need to register a custom editor in initBinder.

Up vote 0 down vote favorite share g+ share fb share tw.

Public String myActionHandler(ModelMap model, @RequestParam MyPojoBean myBean){ ... } I'm sure I've seen this somewhere, but I'm not sure where. Is there a simple code example for this? If the above is possible, how can I catch the exception if the request doesen't match the Bean?

Java spring-mvc link|improve this question asked Mar 21 '11 at 2:56Eran Medan3,97021958 85% accept rate.

You need to register a custom editor in initBinder: @InitBinder public void initBinder(WebDataBinder binder) { binder. RegisterCustomEditor(MyPojoBean. Class, new MyPojoEditor()); } class MyPojoEditor extends java.beans.

PropertyEditorSupport { @Override public String getAsText () {...} @Override public void setAsText (String s) {...} }.

You can do this using @InitBinder (see @Abdullah's answer), which is best if you only need to do this for a single class, or using a custom WebArgumentResolver (see this other question), which is more general.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions