2
由於包括<mvc:annotation-driven/>
在將多選列表框的選擇綁定到命令bean上的相應列表屬性時遇到了問題。在引入<mvc:annotation-driven/>
之前,它工作正常。<mvc:annotation-driven />並綁定到集合
我有一個自定義集合編輯器:
@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;
}
});
}
這在以前將導致表單控制器接收List<Field>
代表列表中選擇。但是,自從使用<mvc:annotation-driven/>
我現在得到的是List<List<Field>>
。
任何人都可以幫助闡明這種行爲嗎?
謝謝!這很有用!我在' '下面添加了'AnnotationMethodHandlerAdapter',將它們交換完畢,現在所有的工作都很棒! –
Stuart
我很高興它的工作:) 通常順序是不是在春季配置導入,所以當它有點兒你。 –