首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

记录一个SpringMVC的400异常

2012-08-25 
记录一个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));    }

?即可。

热点排行