无法将类型 java.lang.String 的 属性 值转换为 属性 dateEmp 所需的类型 java.util.Date;
Failed to convert property value of type java.lang.String to required type java.util.Date for property dateEmp;
一个java ee项目使用spring框架([=17=]-boot)。
在你的控制器中为提到的日期格式添加这个,更多细节你可以参考https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/WebDataBinder.html
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true));
}
通过应用程序属性文件设置全局日期时间格式,如下所示:
spring.mvc.format.date=yyyy-MM-dd
一个java ee项目使用spring框架([=17=]-boot)。
在你的控制器中为提到的日期格式添加这个,更多细节你可以参考https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/bind/WebDataBinder.html
@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true));
}
通过应用程序属性文件设置全局日期时间格式,如下所示: spring.mvc.format.date=yyyy-MM-dd