【发布时间】:2014-11-13 08:55:58
【问题描述】:
我有一个用于日期的 Bean,我在 Spring 配置 xml 中以下列方式从 spring 中注入一个 Date。
<bean id="customer" class="com.my.common.Customer">
<property name="date" value="2014-11-12" />
</bean>
运行后出现以下错误:
Caused by: org.springframework.beans.TypeMismatchException:
Failed to convert property value of type [java.lang.String] to
required type [java.util.Date] for property 'date';
nested exception is java.lang.IllegalArgumentException:
Cannot convert value of type [java.lang.String] to
required type [java.util.Date] for property 'date':
no matching editors or conversion strategy found
为什么会这样?任何人都可以解释为什么它不起作用。
【问题讨论】:
标签: java spring spring-mvc