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.