service层:

@Override

public void batchDeletes(List list) {

creditDao.batchDeletes(list);

}

控制层controller:

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

mapper.xml:

<!--批量删除 -->

<delete id="batchDeletes" parameterType="java.util.List">

DELETE FROM t_credit where t_credit_id in

<foreach collection="list" index="index" item="item" open="(" separator="," close=")">

#{item}

</foreach>

</delete>

页面:

<script type="text/javascript" src="../jquery/jquery-2.1.3.js"></script>

<script type="text/javascript" src="../easyui/jquery.easyui.min.js"></script>

<script type="text/javascript" src="../easyui/locale/easyui-lang-zh_CN.js" ></script>

<script type="text/javascript" src="../easyui/js/index.js"></script>

<link rel="stylesheet" type="text/css" href="../easyui/themes/default/easyui.css" />

<link rel="stylesheet" type="text/css" href="../easyui/themes/icon.css" />

<script type="text/javascript" >

$(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();

});

});

</script>

</head>

<body>

<div id="head">

<form id="registerform" name ="registerform" action="" method="post" enctype="multipart/form-data">

<div class="search-box" style="width:100%;height:40px;">

<label> 登录名: </label>

<input type="text" name="loginName" id="loginName" />

<label style="margin-left:10px;">身份证:</label>

<input type="text" name="IDCard" id="IDCard" />

<label style="margin-left:10px;"> 提交状态:</label>

<select id="status" name="status" style="width:100px;height:20px;">

<option value="">全部</option>

<option value="0">已提交</option>

<option value="1">未提交</option>

</select>

<input type="button"  id="button" value="查询" style="width:65px;height:22px;margin-left:20px;"/>

<input type="submit"  id="exports" value="导出" style="width:65px;height:22px;margin-left:20px;"/>

</div>

<input type="hidden" name="status" id="statushidden" value="${status }" />

<input type="hidden" name="totalcount" id="totalcount" value="${totalcount }" />

<table border="0" cellpadding="0" cellspacing="0">

<tr style="width:100%; height: 50px;">

<td>

<input type="checkbox" id="SelectAll" name="SelectAll" onclick="selectAll();" style="margin-right:5px;"/>全选</td>

<td>序列</td>

<td >登录名</td>

<td >登录密码</td>

<td >确认密码</td>

<td >身份证号</td>

<td >固定电话</td>

<td >手机号码</td>

<td >邮箱</td>

<td >居住地址</td>

<td id="address">提交状态</td>

<td >创建时间</td>

<td >操作</td>

</tr>

<c:forEach var="credit" items="${creditVOList}" varStatus="status">

<tr style="width: 300px;">

<td><input type="checkbox" name="creditIdbox" id="creditIdbox" value="${credit.creditId }"></td>

<td>${status.index}</td>

<td>${credit.loginName}</td>

<td>${credit.loginPwd}</td>

<td>${credit.againPwd}</td>

<td>${credit.IDCard}</td>

<td>${credit.fixedTelephoneNumber}</td>

<td>${credit.telephoneNumber}</td>

<td>${credit.email}</td>

<td id="address">${credit.address}</td>

<td>${credit.status ==0 ? '已提交':'未提交'}</td>

<td>${creditVO.createtime}</td>

<td>

<!--  <a id="delete" href="http://localhost:8080/ssmy/CreditController/deleteuser.do?creditIdbox=${credit.creditId}">删除</a>-->

<a id="delete" href="http://localhost:8080/ssmy2/CreditController/deleteuser.do?creditIdbox=${credit.creditId}">删除</a>

</td>

</tr>

</c:forEach>

</table>

<c:if test="${empty creditVOList }">

没有任何员工信息.

</c:if> <br/>

<input type="button" value="删除" id ="deleteuser" >

<input type="text" name="username"/>

<input type="file" name="uploadFile"/>

<input type="submit" id="uploadFile" name="开始上传文件" value="开始上传文件"/>

<div id="box" style="border: 1px solid #ccc;"></div

</form>

service层:@Override public void batchDeletes(List list) { creditDao.batchDeletes(list); } 控制层controller/** * 批量删除 batch */ @RequestMapping(value="/batchDeletes") @ResponseBody public List<Credit> batchDeletes(HttpServletRequest request,HttpServletResponse response){ String items = request.getParameter("creditIdbox"); List<String> delList = new ArrayList<String>(); String[] strs = items.split(","); for (String str : strs) { delList.add(str); } creditService.batchDeletes(delList); List<Credit> list=creditService.queryUserInfo(null); ModelAndView mv = new ModelAndView(); Map<String, Object> model = new HashMap<String, Object>(); model.put("creditVOList", list); mv.addAllObjects(model); mv.setViewName("queryregister"); return list; } mapper.xml<!--批量删除 --> <delete id="batchDeletes" parameterType="java.util.List"> DELETE FROM t_credit where t_credit_id in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </delete>页面:<script type="text/javascript" src="../jquery/jquery-2.1.3.js"></script><script type="text/javascript" src="../easyui/jquery.easyui.min.js"></script><script type="text/javascript" src="../easyui/locale/easyui-lang-zh_CN.js" ></script><script type="text/javascript" src="../easyui/js/index.js"></script><link rel="stylesheet" type="text/css" href="../easyui/themes/default/easyui.css" /><link rel="stylesheet" type="text/css" href="../easyui/themes/icon.css" /><script type="text/javascript" > $(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(); }); }); </script></head><body><div id="head"> <form id="registerform" name ="registerform" action="" method="post" enctype="multipart/form-data"> <div class="search-box" style="width:100%;height:40px;"> <label> 登录名: </label> <input type="text" name="loginName" id="loginName" /> <label style="margin-left:10px;">身份证:</label> <input type="text" name="IDCard" id="IDCard" /> <label style="margin-left:10px;"> 提交状态:</label> <select id="status" name="status" style="width:100px;height:20px;"> <option value="">全部</option> <option value="0">已提交</option> <option value="1">未提交</option> </select> <input type="button" id="button" value="查询" style="width:65px;height:22px;margin-left:20px;"/> <input type="submit" id="exports" value="导出" style="width:65px;height:22px;margin-left:20px;"/> </div> <input type="hidden" name="status" id="statushidden" value="${status }" /> <input type="hidden" name="totalcount" id="totalcount" value="${totalcount }" /> <table border="0" cellpadding="0" cellspacing="0"> <tr style="width:100%; height: 50px;"> <td> <input type="checkbox" id="SelectAll" name="SelectAll" onclick="selectAll();" style="margin-right:5px;"/>全选</td> <td>序列</td> <td >登录名</td> <td >登录密码</td> <td >确认密码</td> <td >身份证号</td> <td >固定电话</td> <td >手机号码</td> <td >邮箱</td> <td >居住地址</td> <td id="address">提交状态</td> <td >创建时间</td> <td >操作</td> </tr> <c:forEach var="credit" items="${creditVOList}" varStatus="status"> <tr style="width: 300px;"> <td><input type="checkbox" name="creditIdbox" id="creditIdbox" value="${credit.creditId }"></td> <td>${status.index}</td> <td>${credit.loginName}</td> <td>${credit.loginPwd}</td> <td>${credit.againPwd}</td> <td>${credit.IDCard}</td> <td>${credit.fixedTelephoneNumber}</td> <td>${credit.telephoneNumber}</td> <td>${credit.email}</td> <td id="address">${credit.address}</td> <td>${credit.status ==0 ? '已提交':'未提交'}</td> <td>${creditVO.createtime}</td> <td> <!-- <a id="delete" href="http://localhost:8080/ssmy/CreditController/deleteuser.do?creditIdbox=${credit.creditId}">删除</a>--> <a id="delete" href="http://localhost:8080/ssmy2/CreditController/deleteuser.do?creditIdbox=${credit.creditId}">删除</a> </td> </tr> </c:forEach> </table> <c:if test="${empty creditVOList }"> 没有任何员工信息. </c:if> <br/> <input type="button" value="删除" id ="deleteuser" > <input type="text" name="username"/> <input type="file" name="uploadFile"/> <input type="submit" id="uploadFile" name="开始上传文件" value="开始上传文件"/> <div id="box" style="border: 1px solid #ccc;"></div> </form>

mybatis springmvc批量删除 2最新的更多相关文章

  1. Mybatis实现批量删除数据

    Mybatis实现批量删除操作 学习内容: 1. 使用 2. 代码实现 2.1 UserMapper.java 接口 2.2 UserMapper.xml 总结: 学习内容: 1. 使用 这里通过动态 ...

  2. mybatis的批量删除

    公司工程用的是Mybatis的example的类,自动生成了对数据库的操作,批量操作的今天用到了,两种方式,一种需要拓展它生成的类,另一种自带的. 批量删除的id是以集合List传递 id以List& ...

  3. (后端)Mybatis实现批量删除操作(转)

    原文地址:https://blog.csdn.net/javaee_sunny/article/details/52511842 一. 这里主要考虑两种参数类型:数组或者集合. 而这点区别主要体现在E ...

  4. mybatis的批量删除操作

    需求描述:将符合某条件的几条记录删除 解决思路:对于多个id,可以使用sql关键词 in ,只要满足数据库的id在你的id集合或者list中,就删除,从而实现批量删除.循环delete方法是在是low ...

  5. Mybatis实现批量删除

    知识点:当传入参数为数组时,XX.xml文件中,标签为collection属性 参考博客:https://blog.csdn.net/javaee_sunny/article/details/5251 ...

  6. springboot + ajax + mybatis 实现批量删除

    实现思路: 1. checkbox全选获取批量删除的id数组 2. ajax以字符串的形式将id数组传给控制器 3. 控制器将字符串分割成List数组作为参数传给mapper 具体代码: 1. 前端代 ...

  7. mybatis postgresql 批量删除

    一.需求介绍 前端是一个列表页面,列表可以进行复选框的选择,后台进行关联表数据的删除. 二.框架介绍 springboot+mybatis 数据库用的postgresql 三.具体代码(前端js) 1 ...

  8. Mybatis批量删除之Error code 1064, SQL state 42000;

    (一)小小的一次记载. (二):最近的项目都是使用MyBatis,批量新增自己都会写了,但是一次批量删除可把我给折腾了下,写法网上都有,但是照着做就是不行,最后问公司的人,问网友才得到答案,那就是jd ...

  9. 161102、MyBatis中批量插入

    方法一: <insert id="insertbatch" parameterType="java.util.List"> <selectKe ...

随机推荐

  1. 字符串格式化str.format

    一.字符串格式化之str.format 1.位置参数:用{0},{1},{2}表示位置 v1 = '{1},{0},{1}'.format('a','b') #输出b,a,b 2.关键词参数:用{na ...

  2. 【三支火把】--- 关于UEFI&PCD的总结介绍

    1个人理解 个人理解PCD基本等同于Token,应当算是一种描述性语言,按照规定书写好PCD的配置档,在编译的过程中,会根据你的配置生成同等含义的C文档,而在C文档中对应会出现相应的define或者变 ...

  3. 关于NSFetchedResultsController的一些用法

    如何在iPhone等设备持久保存数据,需要用到Core Data,它能帮你快速而有效率的完成数据储存,Core Data 编程经常用到 NSFetchedResultsController这个类,刚开 ...

  4. 在docker容器中安装vim命令进行编辑文件

    首先执行: 执行apt-get update, 然后再次执行apt-get install vim即可成功安装vim. 然后我们就可以使用vim编辑 如果不进行更新就会报错: 此时会报出bash: v ...

  5. csv HTTP简单表服务器

    HTTP Simple Table Server Download Performance testing with JMeter can be done with several JMeter in ...

  6. POJ1008 Maya Calendar

    题目来源:http://poj.org/problem?id=1008 题目大意: Maya人认为一年有365天,但他们有两种日历.一种叫做Haab,有19个月.前18个月每月20天,每个月的名字分别 ...

  7. 查询mysql单库的修改时间,大小

      select database_name,max(last_update) from mysql.innodb_table_stats group by database_name;   SELE ...

  8. IDEA中Java代码存入DB中为乱码

    有一种可能是编译后出现的乱码,可以在Setting的Java compiler中加如下 -encoding UTF-8

  9. 设定计划的SMART原则

    SMART: Specific,Measurable, Attainable,Result-based, Time-based 设定计划,如果不去执行,设定目标,而不去实现,那也算是背叛自己的诺言,终 ...

  10. 原 tomcat的server.xml配置文件中三个端口的作用

    以Tomcat7.0为例, 在安装目录下. conf/server.xml 中可以配置三个端口号, 如果使用多个tomcat 是需要配置这三个. 该Connector 用于监听请求. protocol ...