首页 > 代码库 > 批量删除实现js+springmvc
批量删除实现js+springmvc
前台的控件
<input type=‘checkbox‘ name=‘isSelect‘ value=http://www.mamicode.com/‘"+data[i].id+"‘ ></input></td>";
绑定按钮:
<input type="button" onclick="delEdu()" value="http://www.mamicode.com/Delete" style="color:#95a5a6; border-radius:5px; vertical-align:middle;height:30px; width:60px; "/>
js响应函数
function delEdu(){ var obj=document.getElementsByName(‘isSelect‘); var s1="Select:"; var ids=‘‘; for(var i=0; i<obj.length; i++){ if(obj[i].checked) ids=ids+obj[i].value+","; //如果选中,将value添加到变量s中 } if(ids==‘‘){
alert("Please choose one!"); } else{ $.get("/portal/edu/delEduList?ids="+ids,function(data){ if("success"==data.result){ // alert("Delete Done!"); window.location.reload(); //load(pn,delFlag); } else{ alert("Error!"); } }); } }
后台controller:
@RequestMapping("/delEduList") public void delEduList(Long[] ids,HttpServletResponse response){ String result = "{\"result\":\"success\"}"; List<Education> edulistEducations = eduService.getByIds(ids); for(Education edu:edulistEducations){ eduService.delete(edu.getId()); } PrintWriter out = null; response.setContentType("application/json"); try { out=response.getWriter(); out.write(result); } catch (IOException e) { e.printStackTrace(); } }
批量删除实现js+springmvc
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。