【发布时间】:2017-05-28 17:50:39
【问题描述】:
我正在使用以下代码设置日期格式:
@InitBinder
public void initBinder(final WebDataBinder binder) {
binder.initDirectFieldAccess();
final SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
并从 jsp 以相同格式发送日期,但出现以下错误:
无法将类型 [Java.Lang.String] 的属性值转换为属性 BidDate 所需的类型 [Java.Util.Date];嵌套异常是 Java.Lang.IllegalArgumentException:无法解析日期:无法解析日期:“05/28/2017”
【问题讨论】:
标签: java spring-mvc model-view-controller