//标物配置 public Vector getObjMaterReByPid(String pids) throws ServiceException { DAORefMaterReceive daoreceive = (DAORefMaterReceive) getDao(DAORefMaterReceive.DAO_NAME); Vector result = new Vector() ; String[] parentIDs = pids.split(",") ; try{ for(int i=0 ;i<parentIDs.length ;i++ ) { ObjMaterReceive materReceive = daoreceive. selectByPid(Integer.parseInt(parentIDs[i])) ; if(materReceive.getPlandes().equals("") || null==materReceive.getPlandes()) { }else { String[] plandes = materReceive.getPlandes().split("/") ; String[] receiveCons = materReceive.getReceiveCons().split("/") ; for(int j=0 ;j<plandes.length ;j++ ) { String receiveCon = "" ; if( receiveCons.length<=j ) { receiveCon = "" ; }else { receiveCon = receiveCons[j] ; } materReceiven.setPlandes(plandes[j]) ; materReceive.setReceiveCons(receiveCon) ; result.add(materReceive) ; } } } }catch(DaoException e) { e.printStackTrace() ; } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return result ; } 这样导致的结果, 两个对象的实体一样,而且以后一个为准。 更改后: //标物配置 public Vector getObjMaterReByPid(String pids) throws ServiceException { DAORefMaterReceive daoreceive = (DAORefMaterReceive) getDao(DAORefMaterReceive.DAO_NAME); Vector result = new Vector() ; String[] parentIDs = pids.split(",") ; try{ for(int i=0 ;i<parentIDs.length ;i++ ) { ObjMaterReceive materReceive = daoreceive. selectByPid(Integer.parseInt(parentIDs[i])) ; if(materReceive.getPlandes().equals("") || null==materReceive.getPlandes()) { }else { String[] plandes = materReceive.getPlandes().split("/") ; String[] receiveCons = materReceive.getReceiveCons().split("/") ; for(int j=0 ;j<plandes.length ;j++ ) { ObjMaterReceive materReceivenew = new ObjMaterReceive() ; BeanUtils.copyProperties(materReceivenew, materReceive) ; String receiveCon = "" ; if( receiveCons.length<=j ) { receiveCon = "" ; }else { receiveCon = receiveCons[j] ; } materReceivenew.setPlandes(plandes[j]) ; materReceivenew.setReceiveCons(receiveCon) ; result.add(materReceivenew) ; } } } }catch(DaoException e) { e.printStackTrace() ; } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return result ; } 每次加给result之前都是一个新NEW出的对象,这样得出的结果如下: BeanUtils.copyProperties(materReceivenew, materReceive) ; 这个方法的作用是对象复制,