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