记录一个SpringMVC的400异常

记录一个SpringMVC的400错误用Spring MVC提交一个表单时报400错误:The request sent by the client was sy

记录一个SpringMVC的400错误

用Spring MVC提交一个表单时报400错误:The request sent by the client was syntactically incorrect ().

原来是其中一个日期字段为空所致。代码如下:

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

?只用修改为:

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

?即可。