checkbox后台增删

来源:互联网 发布:泰州网络公关技巧 编辑:程序博客网 时间:2024/06/04 22:12


问题:前台勾选的分类复选框,更改分类后,后台如何判断提交上来的分类,

哪些是要新增的分类,哪些又是需要删掉的分类


// 检查要删数据还是增数据

public void planClassInsert(intplanid, List<String>str, List<String>str2) {

Collectionexists=new ArrayList<String>(str);

Collectionnotexists=new ArrayList<String>(str);

Collectionisexists=new ArrayList<String>(str2);

  exists.removeAll(str2);

  System.out.println("需要添加的:"+exists);

  notexists.removeAll(exists);

  System.out.println("不需要动的:"+notexists);

  isexists.removeAll(notexists);

  System.out.println("需要删除的:"+isexists);

 

  //添加

  for (Objects :exists) {

  System.err.println("//循环增加方案分类记录");

productPlanService.addPlanClass(planid,Integer.parseInt(s.toString()));

  }

  //删除

  for (Objectc :isexists) {

  productPlanService.delPlanClass(planid,Integer.parseInt(c.toString()));

  }

}

原创粉丝点击