jsp页面代码:
<input type="checkbox" id="subcheck" name="subcheck" class="checkboxes" value="${teacher.id}" />
js代码:
function batchDeletes(){
var checkedNum = $("input[name = 'subcheck']:checked").length;
if(checkedNum == 0) {
alert("请至少选中一项!");
return false;
}
if(confirm("确定删除所选项目?")){
var checkedList = new Array();
$("input[name = 'subcheck']:checked").each(function (){
checkedList.push($(this).val());
});
$.ajax({
type: "POST",
url: "rest/teacher/batchDeletes.action",
data: {"ids": checkedList.toString()},
datatype: "html",
success: function (data) {
$("[name=‘checkbox‘]:checkbox").attr("checked", false);
art.dialog.tips('删除成功!');
setTimeout("location.reload()", 1000);//页面刷新
},
error:function(data){
art.dialog.tips('删除失败!');
}
});
}
}
controller代码:
@RequestMapping("/batchDeletes")
public void batchDeletes(HttpServletRequest request){
System.out.println(1);
String items = request.getParameter("ids");
List<String> delList = new ArrayList<String>();
String[] strs = items.split(",");
System.out.println(2);
for (String str : strs) {
delList.add(str);
}
basicTeacherService.batchDeletes(delList);
}
mapper.xml页面代码:
<delete id="batchDeletes" parameterType="java.lang.Long">
delete from basic_teacher where id in
<foreach collection="list" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
麻烦各路大神给看看到底是哪里出了问题哈,谢谢