您的位置:首页 > 产品设计 > UI/UE

Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for pr

2015-12-25 15:24 826 查看
在使用日期控件时,向Controller中进行传值时会报错如下的错误:



所以我们要进行一下日期的转换。在Controller中初始化一下日期的格式。

@InitBinder
public void initBinder(WebDataBinder binder){
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm"); //时间格式
binder.registerCustomEditor(Date.class, "begintime", new CustomDateEditor(timeFormat, false));
binder.registerCustomEditor(Date.class, "endtime", new CustomDateEditor(timeFormat, false));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); //日期格式
binder.registerCustomEditor(Date.class, "setuptime", new CustomDateEditor(dateFormat, true));
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: