异常处理:No value specified for ‘Date‘

一.异常出现原因
使用 BeanUtils.copyProperties(model,bo),数据源对象model有一个参数是java.util.Date类型,由于导入的是org.apache.commons.beanutils.BeanUtils 没有初始化值,导致调用BeanUtils.copyProperties方法时,
报错No value specified for Date

二.解决方法

1.在copy之前加上

ConvertUtils.register(new DateConverter(null), java.util.Date.class);

2.Import导入BeanUtils类的时候, 选择

org.springframework.beans.BeanUtils

就OK了




后传:我发现我的白鞋子穿脏了以后,我对象会给我刷的很干净,所以我决定从此以后就只买白色鞋子啦。

猜你喜欢

转载自blog.csdn.net/weixin_43945983/article/details/105409099