界面往后台传回两个对象:一个 ArrayList<A>() 、一个B。到service 时,
ss = ArrayList<A>();
b =B;
for(A a : ss){
字段 x =a .getX(); //从a中获得字段x
b.setX(x); //把x set到B中
b.saveOne; //保存B
}
假如循环两遍,B第一遍是保存,第二编变成了对第一遍的修改,原因?
(底层Mybatis)
解决办法是,B由service 自己new 出,就没问题了。
for(A a : ss){
字段 x =a .getX(); //从a中获得字段x
B b = new B();
b.setX(x); //把x set到B中
b.saveOne; //保存B
}