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

springmvc 时间类型参数接收

2014-10-11 00:00 393 查看
摘要: springmvc 时间类型参数接收

{"success":false,"msg":"org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors\nField error in object 'vip' on field 'vip_regtime': rejected value [2014-10-11]; codes [typeMismatch.vip.vip_regtime,typeMismatch.vip_regtime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [vip.vip_regtime,vip_regtime]; arguments []; default message [vip_regtime]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'vip_regtime'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: \"2014-10-11\"]"}

以上异常内容

/**
* 时间转换器
*/
@InitBinder
public void initBinder(WebDataBinder binder) {
DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
fmt.setLenient(false);
CustomDateEditor dateEditor = new CustomDateEditor(fmt, true);
binder.registerCustomEditor(Date.class, dateEditor);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: