BeanUtils 使用问题

 在struts2中Action若实现ModelDriven一般就会用到BeanUtils工具类复制实例对象的属性值,
 
BeanUtils.copyProperties(tempEducation, education);在导包的时候要特别小心,情况如下:
 
import org.springframework.beans.BeanUtils;
在spring中,copyProperties(Object source; Object target);  //前面是源实例对象,后面是目标实例对象
 
 
import org.apache.commons.beanutils.BeanUtils;    
而在commons中,copyProperties(Object target ; Object source);//前面是目标实例对象,后面是源实例对象
 
 
如果在打代码的时候太快没有看到相关的方法注释就很容易弄错位置
呵呵,小问题 以后注意

posted on 2012-12-23 23:42  keep_up  阅读(272)  评论(0)    收藏  举报

导航