• 批量删除实现js+springmvc


    前台的控件

    <input type='checkbox' name='isSelect' value='"+data[i].id+"' ></input></td>";
    

    绑定按钮:

    <input type="button"  onclick="delEdu()" value="Delete" style="color:#95a5a6;  border-radius:5px; vertical-align:middle;height:30px;  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();
    	    }
    	}	
    
  • 相关阅读:
    模板template用法
    关联式容器MAP的用法----类似与python中的dict
    迭代器iterator
    c++中的vertor
    Git操作(git reset & get revert)
    代码度量标准
    __attribute__关键字
    Centos7.2部署.Net Core2.0 WebApi
    通过nginx 访问 centos 7 服务器上的.Net Core
    ASP.NET Core部署到CentOS7,使用Nginx代理
  • 原文地址:https://www.cnblogs.com/wujixing/p/5853918.html
Copyright © 2020-2023  润新知