BeanUtils.copyProperties 复制list
解决BeanUtils.copyProperties 不可以复制list
文章共130字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
使用BeanUtis.copyProperties 只能复制对象不可以复制list
BeanUtils.copyProperties(要转换的类, 转换后的类);
List<studentDao> studDao = new ArrayList<studentDao>();
List<student> list = studentService.list();
list.forEach(stu ->{
studentDao userVO = new studentDao();
BeanUtils.copyProperties(stu, userVO);
studDao.add(userVO); });
先将要转换的liat遍历创建要接收的list泛型对象
将遍历的值拷贝到泛型对象中
再add将泛型对象放到实体类中
即可解决
更多推荐
已为社区贡献1条内容
所有评论(0)