//获取一个数组id
String [] ids = request.getParameterValues("sel");
//数组id作为参数传入方法
public int delMorePets(String[] ids) {
StringBuffer sBuffer = new StringBuffer(); //new一个StringBuffer
if (ids != null) {
//循环读取出数组中的id
for (int i = 0; i < ids.length; i++) {
sBuffer.append("'").append(ids[i]).append("',"); //给每个Id前后加单引号和一个逗号隔开
}
}
//编写sql语句 使得要被删除的记录Id in 数组id中
String sql = "delete from PetInfo where petID in ("
+ sBuffer.substring(0, sBuffer.length() - 1) + " )";
//最后返回sql语句
return this.execueSQL(sql, null);
}

被折叠的 条评论
为什么被折叠?



