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));
}
所以我们要进行一下日期的转换。在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));
}
相关文章推荐
- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe
- Mosquitto support websocket
- 实现UITextView的placeholder效果
- UI 相关配置 包含wtl 和mfc
- Detail Disclosure Button and Segues
- 两个UIScrollView同步滚动
- [leetcode 288] Unique Word Abbreviation
- cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=../build/ ..
- 代码手写UI,xib和StoryBoard间的博弈,以及Interface Builder的一些小技巧
- Android酷炫实用的开源框架(UI框架)
- IOS 的 7 中手势的介绍 和详细使用(UIGestureRecognizer) UIScreenEdgePanGestureRecognizer
- Executors.newFixedThreadPool和ArrayBlockingQueue一点使用心得
- UIGestureRecognizer手势识别详解
- iOS流布局UICollectionView系列六——将布局从平面应用到空间
- CC2541 128bit UUID 官方教程有错修改方法!
- IOS给UILabel文本框增加下划线和中划线
- ArrayBlockingQueue和LinkedBlockingQueue的区别
- 分享个Duilib中基于wke的浏览器控件
- [iPhone开发]UITextField下拉框的实现
- ubuntu分区移动导致的grub rescue: no such partition解决方法