一个删除例子
JSP页面代码:
$("#btn_delete").click(function(){
var checkSum=$("[name='ckh']:checked");
if(checkSum.size()==0){
alert("请选中需要删除的记录");
}
else{
$.messager.confirm('Confirm', '是否删除?', function(r){
if (r){
//利用数组
var deleteIds ="" ;
for(var i=0; i<checkSum.size(); i++){
deleteIds +=checkSum.eq(i).val()+',' ;
}
$.ajax({
type : 'POST',
url : '${ctx}/jf/custom/arraryDeleted',
data : {'deleteIds':deleteIds },
dataType : 'text',
success : function(data) {
$(".l-btn-empty").eq(4).click();
}
});
}
});
}
});
后台代码:
//利用数组删除
public void arraryDeleted() {
String deleteIds = this.getPara("deleteIds");
if(StringUtils.isNotBlank(deleteIds)){
String[] deleteId = deleteIds.split(",");
for (String str : deleteId) {
String delSql = "delete from search_info where ID = ?";
System.out.println(str);
int a =Db.update(delSql,new Object[]{str});
System.out.println(a);
//插入操作日志
insertLog("删除搜索条件","删除","deleteId:"+deleteId);
}
}
super.renderText("123"); //返回给前端
}