在springmvc中如果表单属性的类型是日期型时,从页面绑定字符串数据会出错
Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'expert.birthdate'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'birthdate': no matching editors or conversion strategy found
解决方法
1.控制器继承 extends SimpleFormController
2.重写initBinder方法
注意SimpleDateFormat日期格式与页面日期格式要一致!
Failed to convert property value of type [java.lang.String] to required type [java.util.Date] for property 'expert.birthdate'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [java.lang.String] to required type [java.util.Date] for property 'birthdate': no matching editors or conversion strategy found
解决方法
1.控制器继承 extends SimpleFormController
2.重写initBinder方法
注意SimpleDateFormat日期格式与页面日期格式要一致!