Resolves the HTTP Status 405-http method POST are not supported by this URL detailed solution

Source: Internet
Author: User

There are two issues with this error message:

1, in the servlet does not invoke the post () method caused by the

2, in the Serlvet jump does not use the outside jump (Response.sendredirect ())

When I was doing my project, I encountered a 1 error and did not call post () in the servlet. When I submit a XMLHttpRequest request to the servlet in the JSP page, The post () is not used in the corresponding servlet, so this error is reported. Solution:

It's OK to call this method in the servlet.

For friends who encounter 2 of errors, you can use the following solution:

Put Request.getrequestdispatcher ("findbyidservlet?id=" +commentpostid). Forward (request, response);

Changed into Response.sendredirect ("findbyidservlet?id=" +commentpostid);

the difference between redirect and forward:

1) redirect Mode
Response.sendredirect ("test.jsp"); The path to the
page is a relative path. Sendredirect can jump to any page, not necessarily limited to this web application, such as:
Response.sendredirect ("http://www.baidu.com"); The browser's address bar changes after the

Jump, which becomes the address of the page you are jumping to.
this way to pass the value out, you can only take parameter in the URL or in the session, can not use Request.setattribute to pass.

2) forward mode
RequestDispatcher dispatcher = Request.getrequestdispatcher ("/a.jsp");
Dispatcher. Forward (request, response); The path to the
page is a relative path. The forward method can only jump to a page in this Web application. The browser address bar does not change after the

jump.
Use this way to jump, you can use three ways to pass values: URL with parameter,session,request.setattribute

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.