jsp页面:
批量删除
表格:
js(提交):
function confirmDelMany(){ var checkedNum = $("input[name='ids']:checked").length; if(checkedNum==0){ alert("请至少选择一项!"); return false; } if(confirm("您确定要删除吗?")){ $("#form").submit(); } }
Controller.java
@RequestMapping("/deleteMenuBatch") public String deleteMenuBatch(String[] ids,HttpServletRequest request ,HttpServletResponse resp){ Listlist2 = new ArrayList ();// ModelAndView mv = new ModelAndView("workerOn"); for(String string:ids){ System.out.println(string); int e = Integer.parseInt(string); list2.add(e); } for (Integer integer : list2) { System.out.println(integer); } int i =workerService.deleteMenuBatch(list2); if(i>0){ try { resp.setCharacterEncoding("UTF-8"); resp.getWriter().write( " "); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } HttpSession session = request.getSession(); System.out.println(session.getAttribute("projectWorktypeId")); return "redirect:/worker/findAllWorker?projectWorktypeId="+(Integer)session.getAttribute("projectWorktypeId"); }
Mapper.xml
update m_worker_project set deleted=1 where id in #{item}
另需mapper.java、Service.java、serviceImpl.java等文件中的相应接口及实现方法;