jsp页面用表格显示数据库的信息,想在每一行后边加一个删除按钮,点一下删除数据库信息~
删除按钮提交参数到servlet然后删除数据库信息跟当前jsp页面的本行数据。con=DriverManager.getConnection("jdbc:odbc:stu...
删除按钮提交参数 到servlet 然后删除数据库信息跟当前jsp页面的本行数据。
con=DriverManager.getConnection("jdbc:odbc:student","sa","sa");
sql=con.createStatement();
String delete="<TD><input type='button' value='删除' onclick='delete(this)' /></TD>";
rs=sql.executeQuery("SELECT * FROM people");
out.print("<TABLE Border>");
out.print("<TR>");
out.print("<TH width=100>"+"社团名");
out.print("<TH width=100>"+"创始人");
out.print("<TH width=100>"+"社团管理员");
out.print("<TH width=100>"+"社团类型");
out.print("<TH width=100>"+"删除");
out.print("</TR>");
while(rs.next())
{
out.print("<TR>");
out.print("<TD>"+rs.getString(1)+"</TD>");
out.print("<TD>"+rs.getString(2)+"</TD>");
out.print("<TD>"+rs.getString(3)+"</TD>");
out.print("<TD>"+rs.getString(4)+"</TD>");
out.print(delete);
out.print("</TR>");
}
out.print("</TABLE>");
con.close();
}
哪位大侠 可以帮帮忙~最好是有代码 谢谢了~~~ 展开
con=DriverManager.getConnection("jdbc:odbc:student","sa","sa");
sql=con.createStatement();
String delete="<TD><input type='button' value='删除' onclick='delete(this)' /></TD>";
rs=sql.executeQuery("SELECT * FROM people");
out.print("<TABLE Border>");
out.print("<TR>");
out.print("<TH width=100>"+"社团名");
out.print("<TH width=100>"+"创始人");
out.print("<TH width=100>"+"社团管理员");
out.print("<TH width=100>"+"社团类型");
out.print("<TH width=100>"+"删除");
out.print("</TR>");
while(rs.next())
{
out.print("<TR>");
out.print("<TD>"+rs.getString(1)+"</TD>");
out.print("<TD>"+rs.getString(2)+"</TD>");
out.print("<TD>"+rs.getString(3)+"</TD>");
out.print("<TD>"+rs.getString(4)+"</TD>");
out.print(delete);
out.print("</TR>");
}
out.print("</TABLE>");
con.close();
}
哪位大侠 可以帮帮忙~最好是有代码 谢谢了~~~ 展开
展开全部
$.post("servlet/deleteServlet", stuId, function(data){
alert("删除成功");
});
deleteServlet里面是删除的逻辑
long stuId = request.getParameter("stuId");
con=DriverManager.getConnection("jdbc:odbc:student","sa","sa");
sql=con.createStatement();
sql.executeUpdate("delete from people where pId = "+stuId);
凑合看下吧。好长时间没写过jsp了。
alert("删除成功");
});
deleteServlet里面是删除的逻辑
long stuId = request.getParameter("stuId");
con=DriverManager.getConnection("jdbc:odbc:student","sa","sa");
sql=con.createStatement();
sql.executeUpdate("delete from people where pId = "+stuId);
凑合看下吧。好长时间没写过jsp了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询