问题描述:
list中再定义一个list对象,循环赋值不同的list数据,结果全部都累加到每条数据中了,每条数据中都出现重复数据。
问题解决:
1.创建树结构方法信息
2.创建一个新的 List 对象,避免引用问题
3.使用 GongkuangMethodDictVo 的拷贝构造函数
public class PlanSchemeProductionGongkuangStatus
{。。。。。。/** 创建树结构方法信息 */private List<GongkuangMethodDictVo> gongkuangMethodDicList;public List<GongkuangMethodDictVo> getGongkuangMethodDicList() {return gongkuangMethodDicList;}public void setGongkuangMethodDicList(List<GongkuangMethodDictVo> gongkuangMethodDicList) {// 创建一个新的 List 对象,避免引用问题this.gongkuangMethodDicList = new ArrayList<>();for (GongkuangMethodDictVo gongkuangMethodDictVo : gongkuangMethodDicList) {// 使用 GongkuangMethodDictVo 的拷贝构造函数this.gongkuangMethodDicList.add(new GongkuangMethodDictVo(gongkuangMethodDictVo));}}。。。。。。
}