在jsp页面怎样通过servlet删除一行数据 50
welcome.jsp页面:<ahref='delete?id="+id+"'>delete</a>servlet为/delete的servlet类:protectedv...
welcome.jsp 页面:
<a href='delete?id=" + id + "'>delete</a>
servlet为 /delete 的servlet类:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
String id = request.getParameter("id");
String sql = "DELETE FROM StudentInfo WHERE id='" + id + "'";
DBUtil db = new DBUtil();
db.exeDelete(sql); // 删除执行
response.sendRedirect("welcome.jsp");
}
问题是:为什么报错405 Method Not Allowed
HTTP Status 405 – Method Not Allowed
Type Status Report
Message HTTP method GET is not supported by this URL
Description The method received in the request-line is known by the origin server but not supported by the target resource.
Apache Tomcat/8.5.23 展开
<a href='delete?id=" + id + "'>delete</a>
servlet为 /delete 的servlet类:
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
String id = request.getParameter("id");
String sql = "DELETE FROM StudentInfo WHERE id='" + id + "'";
DBUtil db = new DBUtil();
db.exeDelete(sql); // 删除执行
response.sendRedirect("welcome.jsp");
}
问题是:为什么报错405 Method Not Allowed
HTTP Status 405 – Method Not Allowed
Type Status Report
Message HTTP method GET is not supported by this URL
Description The method received in the request-line is known by the origin server but not supported by the target resource.
Apache Tomcat/8.5.23 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询