SSM项目的批量删除
UserController
@RequestMapping(“deleteAll.do”)
@ResponseBody
public String deleteAll(String userList){
String[] strings = userList.split(",");
List ids = new ArrayList<>();
for(String s:strings){
ids.add(Integer.parseInt(s));
}
userService.deleteAll(ids);
return “”;
}
UserMapper.xml
function deleteAll() {
var checkedNum=$(“input[name=‘ids’]:checked”).length;
alert(checkedNum);
if(checkedNum==0){
alert(“请至少选择一个进行删除!!!”);
return;
}
if(confirm(“确认要删除这些用户吗?”)){
var userList=new Array();
KaTeX parse error: Expected '}', got 'EOF' at end of input: … userList.push((this).val())
}
);
alert(userList);
KaTeX parse error: Expected '}', got 'EOF' at end of input: … url: "{pageContext.request.contextPath}/user/deleteAll.do",
data:{userList:userList.toString()},
success:function () {
alert(“删除成功”);
location.reload();
},
error:function () {
alert("删除失败");
}
});
}
}
搭建Springboot项目
Spring Initializr,Maven两种方式均可搭建Springboot项目,Spring Initializr会自动生成一些默认文件,用起来更方便