Why can't I register PropertyEditor for String in Spring MVC?

I am using Spring 3.0.3. I turned it on by ConversionServiceadding this line to my Spring XML configurator.

<mvc:annotation-driven/>

I also use custom ones PropertyEditorfor certain data types, so I registered them for the corresponding data types, such as the following, and they work fine.

webDataBinder.registerCustomEditor(Date.class, new MyPropertyEditor());

I have a special tag library that extends the Spring tag library, and I can use these PropertyEditorthrough getPropertyEditor()of AbstractDataBoundFormElementTag.

I do not understand that I cannot register custom PropertyEditorfor String for some reason. The following will not work.

webDataBinder.registerCustomEditor(String.class, new MyPropertyEditor());

When I do getPropertyEditor(), it always returns ConvertingPropertyEditorAdapterinstead MyPropertyEditor.

This is mistake?

. , . Spring .

+3
1

PropertyEditorRegistrySupport (spring 3.0.5), , , :

customEditors.put(requiredType, propertyEditor);

, . String . , ?

0

Source: https://habr.com/ru/post/1782359/


All Articles