多选框批量删除后台代码

来源:互联网 发布:mac怎么给iphone换铃声 编辑:程序博客网 时间:2024/05/19 13:26
 /**
       *公告管理--可批量删除
     * @throws IOException 
       */
      @RequestMapping(value="delete_notice", method=RequestMethod.POST, produces="text/json;charset=utf-8")
      @ResponseBody
      public Object delete_notice(HttpServletRequest request,HttpServletResponse response) throws IOException{
       String items = request.getParameter("noticeId"); 
       String[] strs = items.split(",");  
       JSONObject data = new JSONObject();
       for (int i = 0; i < strs.length; i++) {   
               
        int notices = Integer.parseInt(strs[i]);  
 
  int n = this.noticeService.delete_notice(notices);
  if (n > 0) {
  data.put("data", "1");
  }else {
  data.put("data", "操作失败");
  }
       }
       response.sendRedirect("knowledge_admin.html");
    return data.toString();
    }