• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic