HTTP method POST is not a supported by this URL resolved

Source: Internet
Author: User

Today wrote a very simple setvlet want to test something, write well after using Postman request error, error content as follows

{    "timestamp":1504170113588,    "Status":405,    "Error":"Method not allowed",    "message":"HTTP Method POST is not a supported by this URL",    "Path":"/vincent/aaa"}

But my console still agreed to the content of my request, baffled, and finally found out that the call to the parent class was not deleted by the Post method

My code is as follows

@WebServlet (Urlpatterns ="/aaa") Public classMyservlet extends httpservlet{@Overrideprotected voiddoget (httpservletrequest request, HttpServletResponse resp) throws Servletexception, IOException {super.doget    (Request, RESP); } @Overrideprotected voidDoPost (httpservletrequest request, HttpServletResponse resp) throws Servletexception, IOException {Inputstrea M InputStream=Request.getinputstream (); BufferedReaderinch=NewBufferedReader (NewInputStreamReader (Request.getinputstream ())); StringBuilder SB=NewStringBuilder (); String Xmlhead=""; String xmlcontent=""; String Line=NULL;  while(line =inch. ReadLine ())! =NULL) {sb.append (line); } System. out. println (SB);    super.dopost (Request, RESP); }}
Super.dopost (Request, RESP), the source code is as follows
protected voidDoPost (httpservletrequest req, HttpServletResponse resp) throws Servletexception, IOException {String Protoco L=Req.getprotocol (); String msg= Lstrings.getstring ("http.method_post_not_supported"); if(Protocol.endswith ("1.1") {resp.senderror (405, MSG); } Else{resp.senderror ( -, MSG); }    }

Have you found that no matter what your request, he has an error.

HTTP method POST is not a supported by this URL resolved

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.