HTTP Status 405 - HTTP method GET is not supported by this URL
2017-05-15 16:16
465 查看
翻译自HTTP method GET is not supported by this URL
You did properly @Override the doGet() method, but you’re still explicitly calling the default implementation for unclear reason.
Get rid of this line and this problem shall disappear.
The HttpServlet basically follows the template method pattern where all non-overridden HTTP methods returns this HTTP 405 error “Method not supported”. When you override such a method, you should not call super method, because you would otherwise still get the HTTP 405 error. The same story goes on for your doPost() method.
你正确地重写了doGet()方法,但是你显式地调用了默认的实现方式
删掉这行代码应该就没有这个问题了。
HttpServlet基本上遵循模板方法模式(template method pattern)的原理,所有没有重写HTTP的方法都将返回HTTP405错误“方法不被支持”。如果你重写这样的一个方法,不能去调用super.xxx,否则就会得到HTTP 405错误。同理,如果在doPost()中调用super.xxx,也会得到405错误。
原文
This is the default response of the default implementation of HttpServlet#doGet(). This means that the doGet() method is not properly being @Overriden, or it is explicitly being called.You did properly @Override the doGet() method, but you’re still explicitly calling the default implementation for unclear reason.
super.doGet(req, resp);
Get rid of this line and this problem shall disappear.
The HttpServlet basically follows the template method pattern where all non-overridden HTTP methods returns this HTTP 405 error “Method not supported”. When you override such a method, you should not call super method, because you would otherwise still get the HTTP 405 error. The same story goes on for your doPost() method.
翻译
这个错误是HttpServlet#doGet()默认实现方法的默认响应。也就是说你没有正确的重写doGet()方法或者显式地调用了默认的实现方式。你正确地重写了doGet()方法,但是你显式地调用了默认的实现方式
super.doGet(req, resp);
删掉这行代码应该就没有这个问题了。
HttpServlet基本上遵循模板方法模式(template method pattern)的原理,所有没有重写HTTP的方法都将返回HTTP405错误“方法不被支持”。如果你重写这样的一个方法,不能去调用super.xxx,否则就会得到HTTP 405错误。同理,如果在doPost()中调用super.xxx,也会得到405错误。
相关文章推荐
- HTTP Status 405 - HTTP method GET is not supported by this URL
- 出现HTTP Status 405 - HTTP method GET is not supported by this URL 原因及解决方法:
- servlet错误:HTTP Status 405 - HTTP method GET is not supported by this URL
- 访问arcgisserver报:HTTP Status 405 - HTTP method GET is not supported by this URL
- HTTP Status 405 - HTTP method GET is not supported by this URL
- 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
- 出现HTTP Status 405 - HTTP method GET 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 is not supported by this URL
- 解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
- 405--HTTP method GET is not supported by this URL
- 405: HTTP method GET is not supported by this URL
- HTTP Status 405 - HTTP method GET is not supported by this URL
- 当编写Servlet时出现type Status report message HTTP method GET is not supported by this URL description The
- HTTP Status 405 - HTTP method POST/GET is not supported by this URLyi
- 405 HTTP method GET 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
- HTTP Status 405 - HTTP method POST is not supported by this URL