您的位置:首页 > 编程语言 > Java开发

springMVC 接受对象 The request sent by the client was syntactically incorrect.

2017-06-03 15:39 281 查看
在接受对象的时候,The request sent by the client was syntactically incorrect.

在接受对象里有个date类,如要date的时候,与springMVC中的机制不相符

在controller类中加入这个。

@InitBinder
public void InitBinder(ServletRequestDataBinder binder){
// 自动转换日期类型的字段格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
}


或者在model类中

@DateTimeFormat(pattern="yyyy-MM-dd")
private Date createDate;    // 建馆时间
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐