BeanUtils copyProperties复制Arraylist [英] BeanUtils copyProperties to copy Arraylist

查看:5678
本文介绍了BeanUtils copyProperties复制Arraylist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道BeanUtils可以将单个对象复制到其他对象。

I know that BeanUtils can copy a single object to other.

可以复制数组列表。

例如:

 FromBean fromBean = new FromBean("fromBean", "fromBeanAProp", "fromBeanBProp");
 ToBean toBean = new ToBean("toBean", "toBeanBProp", "toBeanCProp");
 BeanUtils.copyProperties(toBean, fromBean);

如何实现?

List<FromBean > fromBeanList = new ArrayList<FromBean >();  
List<ToBean > toBeanList = new ArrayList<ToBean >();  
BeanUtils.copyProperties(toBeanList , fromBeanList );

它不适合我。任何人都可以帮助我。

Its not working for me. Can any one please help me.

提前感谢。

推荐答案

如果您有两个等于大小的列表,那么您可以执行以下操作:

If you have two lists of equals size then you can do the following

for (int i = 0; i < fromBeanList.size(); i++) {
     BeanUtils.copyProperties(toBeanList.get(i), fromBeanList.get(i));
}

这篇关于BeanUtils copyProperties复制Arraylist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆