In a jQuery ajax request, HttpServlet Returns [HTTP/1.1 405 Method not allowed], jqueryhttpservlet

Source: Internet
Author: User

In a jQuery ajax request, HttpServlet Returns [HTTP/1.1 405 Method not allowed], jqueryhttpservlet

1. Problems
When jQuery ajax is used to request a Servlet, the success callback function that does not enter ajax is returned, and the browser console displays [HTTP/1.1 405 Method not allowed].


2. Solution
Most of the online surveys are explained as follows:

The vast majority of web servers such as Apache, IIS, and Nginx do not allow static files to respond to POST requests. Otherwise, an "HTTP/1.1 405 Method not allowed" error will be returned. That is, change the method = "post" of the error page form to "get ".


After modifying the ajax request method, neither the post or get methods can be used, but it is a problem with the post and get request methods. The final problem is solved for the following reasons:

The Servlet class that processes the request only overrides the service method, and does not overwrite the doGet and doPost methods. After the doGet and doPost methods are rewritten, ajax returns normally.

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.