• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The request methods other than GET and POST with AJAX in Spring 3.2 don't work

 
Tiny None
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to call a method in Spring (3.2.0) via AJAX using the following jQuery 1.6 (using the PUT method).


It attempts to invoke the following method in Spring.



FireFox responds with the following error.

HTTP Status 405 - Request method 'GET' not supported

type Status report

message Request method 'GET' not supported

description The specified HTTP method is not allowed for the requested resource (Request method 'GET' not supported).

Apache Tomcat/6.0.26


It works with the GET and POST methods and JSON (with Jackson-2.1.1) also works fine in other parts of the application.


If you need to see the dispatcher-servlet.xml file, the full contents is as follows.



How to make HTTP methods other than GET and POST work in Spring 3.2?

I have org.springframework.web.filter.HiddenHttpMethodFilter configured in my web.xml file and Servlet works with other HTTP methods (including GET and POST). The problem in question was also working fine with the Spring framework 3.0.2 with no configurations at all and the PUT method (i.e other than GET and POST) works with with but it doesn't appear to be the case with AJAX in Spring 3.2.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you still need the input. The main problem is that browsers don't support PUT and DELETE, so you have to use this workaround, no matter what Spring version.

Personally, I have also tried doing JQuery ajax and making them PUTs and such, but never could get it to do an actual AJAX PUT or DELETE.

Mark
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no problem at all getting jQuery and Ajax to make requests of all methods including PUT and DELETE. What browser?

Have you used the browser's debugger to view the request and see what's actually being submitted?
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:I have no problem at all getting jQuery and Ajax to make requests of all methods including PUT and DELETE. What browser?

Have you used the browser's debugger to view the request and see what's actually being submitted?


Yeah it was always submitted as a POST for me.

But hey, I haven't finished reading your book yet, so I am not the Ninja like you yet. ;)

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic