Why can I not register a PropertyEditor for String in Spring MVC?
Posted
by
Tom Tucker
on Stack Overflow
See other posts from Stack Overflow
or by Tom Tucker
Published on 2010-12-27T21:17:04Z
Indexed on
2011/01/13
2:53 UTC
Read the original article
Hit count: 391
I'm using Spring 3.0.3. I've enabled the default ConversionService
by adding this line to my Spring configuration XML.
<mvc:annotation-driven/>
I'm also using custom PropertyEditor
's for certain data types, so I've registered them for corresponding data types like the following and they work fine.
webDataBinder.registerCustomEditor(Date.class, new MyPropertyEditor());
I have a custom tag library that extends Spring's Form tag library, and I can acess these PropertyEditor
's through getPropertyEditor()
of AbstractDataBoundFormElementTag
.
What I don't understand is that I can't register a custom PropertyEditor
for String for some reason. The following wouldn't work.
webDataBinder.registerCustomEditor(String.class, new MyPropertyEditor());
When I do getPropertyEditor()
, it always returns a ConvertingPropertyEditorAdapter
, instead of MyPropertyEditor
.
Is this a bug?
EDIT: I realized that I didn't do some stuff right. Spring works just fine.
© Stack Overflow or respective owner