public void deleteStudent(int sid){
DBConnection db=new DBConnection();
PreparedStatement preStmt=null;
try {
preStmt=db.getConn().prepareStatement("delete from student where sid=?");
preStmt.setInt(1, sid);
preStmt.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//对应的jsp页面代码
编号 | 姓名 | 地址 | 爱好 | 更新 | 删除 |
//%内部只能识别java代码
ArrayList students = (ArrayList) request
.getAttribute("students");
if (students != null) {
for (int i = 0; i < students.size(); i++) {
%>
更新 删除}
}
%>