I am experiencing some confusion in the use and purpose of Spring's DataBinder and ConversionService with regards to binding web requests to model objects. This has arisen because I have recently tried to use the JSR-303 validation by adding .
Prior to this I used:
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="mypackage.GlobalWebBindingInitializer" />
</property>
</bean>
This was good because I wanted a global DataBinder that could be used by several Controllers. Within the GlobalWebBindingInitialzer class implement several of these:
binder.registerCustomEditor(MyClass.class, new PropertyEditorSupport(MyClass.class)
However I wanted to use the @Valid annotation and so added . The side-effect of this is that the above AnnotationMethodHandlerAdapter bean is already defined as part of the annotation-driven and so my global data binder is ignored.
So now I have created this class:
public class MyClassConverter implements Converter<String, MyClass>
I am confused. If I want to use should I use conversion service rather than databinder?