struct2问题
Action的删除方法
public void delete() throws Exception{
studentdao.delete(studentBean);
System.out.println(studentBean.getId());
}
DAO层
public boolean delete(StudentBean studentbean) throws Exception{
Connection conn=DBUtil.getConn();
String sql="delete from student where id=?";
PreparedStatement st=conn.prepareStatement(sql);
st.setInt(1, studentbean.getId());
boolean result=st.executeUpdate()>0?true:false;
return result;
}
<form action="Student.action">
<table class="table">
<tr>
<td>id</td>
<td>姓名</td>
<td>密码</td>
<td>操作</td>
</tr>
<c:forEach items="${list }" var="studentBean" >
<tr>
<td>${studentBean.id}</td>
<td>${studentBean.name}</td>
<td>${studentBean.password}</td>
<td><a href="deleteAction?id=${studentBean.id}">删除</a></td>
</tr>
</c:forEach>
</table>
</form>