aspose file tools*
The moose likes Spring and the fly likes The request methods other than GET and POST with AJAX in Spring 3.2 don't work Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "The request methods other than GET and POST with AJAX in Spring 3.2 don Watch "The request methods other than GET and POST with AJAX in Spring 3.2 don New topic
Author

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

Tiny None
Greenhorn

Joined: Jan 23, 2013
Posts: 1
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

Joined: Feb 05, 2001
Posts: 17257
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The request methods other than GET and POST with AJAX in Spring 3.2 don't work