访问Servlet时报如下的错误:
HTTP Status 405 - HTTP method GET is not supported by this URL
type Status report
message HTTP method GET is not supported by this URL
description The specified HTTP method is not allowed for the requested resource.
Apache Tomcat/8.0.9
从错误信息看,是这个URL不支持GET请求方式,可是我继承的HttpServlet已经重载了doGet方法:public class FirstServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
PrintWriter printWriter = resp.getWriter();
printWriter.println("这是第一个Servlet");
<del><span style="color:#ff6666;">super.doGet(req, resp);</span></del>
}
}
哈哈,我再检查了一下代码,发现我调用了父类的doGet方法,
,将调用父类的doGet方法删掉,就OK了。