HTTP method POST is not supported by this URL错误的解决方案
2013-08-28 17:15
435 查看
今天偶尔重新温习了一下BS方面的开发,结果仅仅写了一个简单的servlet,提交之后访问servlet之后总是会报HTTP method POST is not supported by this URL错误, 感到很疑惑,之前在BS开发过程中重来也没有遇到过这类错误,百度一下之后也没有解决问题,最后发现竟然是在重写的doPost多加了一个语句super.doPost导致的,无奈之下只好下了tomcat的原代码,打开javax.servlet.http.HttpServlet.java文件之后才发现超类的doPost方法如下:
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
String protocol = req.getProtocol();
String msg = lStrings.getString("http.method_post_not_supported");
if (protocol.endsWith("1.1")) {
resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
} else {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
}
}
也就是说不管你的http是不是1.1的,都是用resp.sendError方法返回一个http.method_post_not_supported的错误信息给前台界面,把我害的好苦,强烈谴责tomcat代码的注释,应该注明不要加super.doPost,不能总让我们看你们的源代码吧.呵呵 .
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
String protocol = req.getProtocol();
String msg = lStrings.getString("http.method_post_not_supported");
if (protocol.endsWith("1.1")) {
resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
} else {
resp.sendError(HttpServletResponse.SC_BAD_REQUEST, msg);
}
}
也就是说不管你的http是不是1.1的,都是用resp.sendError方法返回一个http.method_post_not_supported的错误信息给前台界面,把我害的好苦,强烈谴责tomcat代码的注释,应该注明不要加super.doPost,不能总让我们看你们的源代码吧.呵呵 .
相关文章推荐
- HTTP method POST is not supported by this URL错误的解决方案
- HTTP method POST is not supported by this URL错误的解决方案
- HTTP method POST is not supported by this URL解决方案
- HTTP method POST is not supported by this URL解决方案
- servlet中使用service()方法出现错误:HTTP method POST is not supported by this URL
- HTTP Status 405 -- HTTP method POST is not supported by this URL
- HTTP method POST is not supported by this URL
- 解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
- HTTP method POST is not supported by this URL
- HTTP method GET is not supported by this URL"的错误
- 关于"HTTP method GET is not supported by this URL"的错误
- J2EE中HTTP method GET/Post is not supported by this URL
- (6) HTTP Status 405 - HTTP method POST is not supported by this URL
- HTTP Status 405 - HTTP method POST is not supported by this URL
- HTTP Status 405 - HTTP method POST is not supported by this URL
- servlet错误:HTTP Status 405 - HTTP method GET is not supported by this URL
- HTTP method POST is not supported by this URL
- HTTP Status 405 - HTTP method POST is not supported by this URL
- servlet错误:HTTP Status 405 - HTTP method GET is not supported by this URL
- HTTP Status 405 - HTTP method GET(POST) is not supported by this URL