service层:
@Override
public void batchDeletes(List list) {
creditDao.batchDeletes(list);
}
控制层controller:
/**
* 批量删除 batch
*/
@RequestMapping(value="/batchDeletes")
@ResponseBody
public List
String items = request.getParameter("creditIdbox");
List
String[] strs = items.split(",");
for (String str : strs) {
delList.add(str);
}
creditService.batchDeletes(delList);
List
ModelAndView mv = new ModelAndView();
Map
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();
});
});
全选 没有任何员工信息. 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
序列
登录名
登录密码
确认密码
身份证号
固定电话
手机号码
邮箱
居住地址
提交状态
创建时间
操作
${status.index}
${credit.loginName}
${credit.loginPwd}
${credit.againPwd}
${credit.IDCard}
${credit.fixedTelephoneNumber}
${credit.telephoneNumber}
${credit.email}
${credit.address}
${credit.status ==0 ? '已提交':'未提交'}
${creditVO.createtime}
全选 序列 登录名 登录密码 确认密码 身份证号 固定电话 手机号码 邮箱 居住地址 提交状态 创建时间 操作 ${status.index} ${credit.loginName} ${credit.loginPwd} ${credit.againPwd} ${credit.IDCard} ${credit.fixedTelephoneNumber} ${credit.telephoneNumber} ${credit.email} ${credit.address} ${credit.status ==0 ? '已提交':'未提交'} ${creditVO.createtime} 删除
Atas ialah kandungan terperinci mybatis springmvc批量删除代码分享. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!