Servlet http method GET is not supported HTTP 405

Source: Internet
Author: User

Write a servlet after the access to throw the "HTTP method GET is not the supported by this URL" error, first find a reason, and then find a solution after the network for related reasons.

The problem is that when you build a servlet with Eclipse, the default call to the parent class is automatically added in Doget and Dopost, with the following red Identification code:


/**     * @see httpservlet#doget (httpservletrequest request, httpservletresponse response) */    protected void Doget (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {        //TODO auto-generated method Stub        super.doget (Request, response);    }    /**     * @see httpservlet#dopost (httpservletrequest request, httpservletresponse response) */    protected void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexception, IOException {        // TODO auto-generated Method Stub        super.dopost (Request, response);    }



At this point, if you call a method of the parent class directly, the Doget or Dopost method of the parent class HttpServlet overrides the method you overridden, and the parent class The default implementation of the HttpServlet Doget or Dopost method is to return an HTTP error with a status code of 405, indicating that the request method for the specified resource is not allowed. Removing the method of calling the parent class from the above code solves the problem.

Servlet http method GET is not supported HTTP 405

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.