当前位置: 代码迷 >> Java Web开发 >> BeanUtils.copyProperties拷贝form到实业bean时出错
  详细解决方案

BeanUtils.copyProperties拷贝form到实业bean时出错

热度:3634   发布时间:2013-02-25 21:09:40.0
BeanUtils.copyProperties拷贝form到实体bean时出错
form属性:
 private String innerId;
 private TbCar tbCar = new TbCar();
 private TbCustomer tbCustomer = new TbCustomer();
 private String zhixing;
 private String zulinPrice = "0";
 private String yajin = "0";
 private String preZujin = "0";
 private String zulinQixian = "0";
 private String chaoshiFee = "0";
 private String lichengMeitian = "0";
 private String outTimeFee = "0";
 private String jingbanren;
 private String yudingDate;
 private String yudingTime;
 private String demo;
bean属性:
 private String innerId;
 private TbCar tbCar = new TbCar();
 private TbCustomer tbCustomer = new TbCustomer();
 private String zhixing;
 private Integer zulinPrice;
 private Integer yajin;
 private Integer preZujin;
 private Integer zulinQixian;
 private Integer chaoshiFee;
 private Integer lichengMeitian;
 private Integer outTimeFee;
 private String jingbanren;
 private Date yudingDate;
 private Time yudingTime;
 private String demo;
异常:java.lang.IllegalArgumentException: argument type mismatch
问题补充:据自己推测应该是复制TbCar和TbCustomer时类型不匹配照成的。请大家帮帮忙。

------解决方案--------------------------------------------------------
如果源是String,目标对象是Integer。匹配难度是很小的。只要check正确也没有问题
如果源是String,目标对象是java.util.Date。你说怎么匹配?就算匹配了,风险也太大了。

这篇文章你可以读下,但是我不推荐你这么做。
http://blog.csdn.net/fableking/archive/2008/07/12/2644351.aspx
  相关解决方案