首页 > 编程语言 > 详细

[Spring MVC] 表单提交日期转换问题,比如可能导致封装实体类时400错误

时间:2018-07-06 00:57:15      阅读:249      评论:0      收藏:0      [点我收藏+]

  三种格式的InitBinder

@InitBinder//https://stackoverflow.com/questions/20616319/the-request-sent-by-the-client-was-syntactically-incorrect-spring-mvc-jdbc-te
public void initBinder(WebDataBinder binder) {
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
sdf.setLenient(true);
binder.registerCustomEditor(Date.class, new CustomDateEditor(sdf, true));
}
@InitBinder// 弟弟通过qq发送的
public void initBinder(ServletRequestDataBinder binder){
binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"),
true));
}
@InitBinder//露露通过飞秋发送的
public void initBinder(ServletRequestDataBinder binder) {
binder.registerCustomEditor(Date.class, new CustomDateEditor(
new SimpleDateFormat("yyyy-MM-dd"), true));
}

[Spring MVC] 表单提交日期转换问题,比如可能导致封装实体类时400错误

原文:https://www.cnblogs.com/zienzir/p/9270808.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!