AI编程助手
AI免费问答

mybatis springmvc批量删除代码分享

巴扎黑   2017-07-24 13:50   2493浏览 原创

service层:

 

@Override

public void batchDeletes(List list) {

creditDao.batchDeletes(list);

 

}

控制层controller:

 

/**
    * 批量删除 batch
    */
   @RequestMapping(value="/batchDeletes")
   @ResponseBody
   public List batchDeletes(HttpServletRequest request,HttpServletResponse response){
       String items = request.getParameter("creditIdbox");
       List delList = new ArrayList();
       String[] strs = items.split(",");
       for (String str : strs) {
           delList.add(str);
       }
       creditService.batchDeletes(delList);
       List list=creditService.queryUserInfo(null);
      ModelAndView mv = new ModelAndView();
      Map model = new HashMap();
      model.put("creditVOList", list);
      mv.addAllObjects(model);
      mv.setViewName("queryregister");
      return list;
   }

mapper.xml:

   

            DELETE FROM t_credit where t_credit_id in

          

            #{item}   

         

   

页面:

 $(function(){

$("#button").click(function(){

   var form=$("#registerform");

   form.prop("action","http://localhost:8080/ssmy2/CreditController/intiqu.do");

   form.submit();

   

});

//方式二:

/*$(function(){

    $("#button").click(function(){

    document.registerform.action="http://localhost:8080/ssmy/CreditController/intiqu.do";

    document.registerform.submit();

 

   });**/

//对查询按钮定死状态

 $("#status").val($("#statushidden").val());

});

   function selectAll(){

     if ($("#SelectAll").is(":checked")) {

         $(":checkbox").prop("checked", true);//所有选择框都选中

     } else {

         $(":checkbox").prop("checked", false);

     }

 }

   $(function(){

   $("#deleteuser").click(function(){

    //判断至少写了一项

          var checkedNum = $("input[name='creditIdbox']:checked").length;

   console.log(checkedNum);

          if(checkedNum==0){

              alert("请至少选择一项!");

              return false;

       }

          if(confirm("确定删除所选项目?")){

               var checkedList = new Array();

               $("input[name='creditIdbox']:checked").each(function(){

                   checkedList.push($(this).val());

               });

               console.log(checkedList[0]);

               $.ajax({

                   type:"POST",

                   url:"http://localhost:8080/ssmy2/CreditController/batchDeletes.do",

                   data:{"creditIdbox":checkedList.toString()},

                   datatype:"json",

                   success:function(data){

                       $("[name='creditIdbox']:checkbox").attr("checked",false);

                       alert('删除成功!');

                       setTimeout("location.reload()",1000);//页面刷新

                   },

                   error:function(data){

                   alert('删除失败!');

                   }

               });

               } 

   /* var form=$("#registerform");

   form.prop("action","http://localhost:8080/ssmy/CreditController/deleteuser.do");

   form.submit();  */

});

   $("#exports").click(function(){

   var form =$("#registerform");

   form.prop("action","http://localhost:8080/ssmy2/CreditController/exprotExcel.do");

   form.submit();

   

   });

    $("#delete").click(function(){

   var form =$("#registerform");

   form.prop("action","http://localhost:8080/ssmy2/CreditController/batchDeletes.do?creditIdbox=${credit.creditId}");

   form.submit();

   

   }); 

   $("#uploadFile").click(function(){

   var form =$("#registerform");

   form.prop("action","http://localhost:8080/ssmy2/CreditController/uploadFile.do");

   form.submit();

   

   });

  });   

全选 序列 登录名 登录密码 确认密码 身份证号 固定电话 手机号码 邮箱 居住地址 提交状态 创建时间 操作
${status.index} ${credit.loginName} ${credit.loginPwd} ${credit.againPwd} ${credit.IDCard} ${credit.fixedTelephoneNumber} ${credit.telephoneNumber} ${credit.email} ${credit.address} ${credit.status ==0 ? '已提交':'未提交'} ${creditVO.createtime} 删除
没有任何员工信息.

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。