Since including <mvc:annotation-driven/> I have experienced a problem when binding the selections of multi-select list box to its corresponding list property on the command bean. Before introducing <mvc:annotation-driven/> it worked correctly.
I have a custom collection editor:
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(List.class, new CustomCollectionEditor(List.class) {
protected Object convertElement(Object element) {
String fieldName = (String)element;
for (Field field : fields) {
if (field.getFieldName().equals(fieldName))
return field;
}
return element;
}
});
}
which previously would result in the form controller receiving a List<Field> representing the list selections. However, since using the <mvc:annotation-driven/> what I now get is a List<List<Field>>.
Can anyone help shed light on this behaviour?
This might not be even close but…
If you create your own
AnnotationMethodHandlerAdapterto set a customwebBindingInitializeron it you need to have<mvc:annotation-driven />after yourAnnotationMethodHandlerAdapter, otherwise the one created by<mvc:annotation-driver />will be in use and your custom binder won’t be in use.Try moving it if it isn’t already last.
Other than that I can only suggest to set a break point inside your binder to see if it is called.