Java 在spring4中,当我设置自定义编辑器属性时,CustomEditorConfiguration抛出错误
当我试图将自定义编辑器映射到Java 在spring4中,当我设置自定义编辑器属性时,CustomEditorConfiguration抛出错误,java,spring,Java,Spring,当我试图将自定义编辑器映射到java.util.Locale时,使用org.springframework.beans.factory.config.customeditorconfigure会引发异常: Cannot convert value of type [org.test.beans.LocalePropertyEditor] to required type [java.lang.Class] for property 'customEditors[java.util.Locale]
java.util.Locale
时,使用org.springframework.beans.factory.config.customeditorconfigure会引发异常:
Cannot convert value of type [org.test.beans.LocalePropertyEditor] to required type [java.lang.Class] for property 'customEditors[java.util.Locale]'
PropertyEditor [org.springframework.beans.propertyeditors.ClassEditor] returned inappropriate value of type [org.test.beans.LocalePropertyEditor]
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:263)
at org.springframework.beans.TypeConverterDelegate.convertToTypedMap(TypeConverterDelegate.java:623)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:208)
at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:458)
我需要转换LocalePropertyEditor类——有效Java时区id的字符串值被转换为时区对象
public class LocalePropertyEditor extends PropertyEditorSupport {
public void setAsText(String text) {
}
}
I am setting it using following entry
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Locale"><bean class="org.test.beans.LocalePropertyEditor" /></entry>
</map>
</property>
</bean>
公共类LocalePropertyEditor扩展了PropertyEditorSupport{
公共void setAsText(字符串文本){
}
}
我正在使用以下条目进行设置
我们需要使用
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="customEditors">
<map>
<entry key="java.util.Locale" value="org.test.beans.LocalePropertyEditor"/>
</map>
</property>
</bean>
Spring将负责bean的实例化。欢迎使用StackOverflow!我有一个prop_conf_spring.XML,其条目如下所示