SpringMVC页面传参到后台,日期字符串报错处理

在controller类中加入如下代码,
如果页面的查询格式都是同一格式的日期,则直接放到BaseController类中即可:

@InitBinder
protected void initBinder(WebDataBinder binder) {
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}

猜你喜欢

转载自blog.csdn.net/yanweihpu/article/details/70448838