Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • 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
  • 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: 17346
11
Mac IntelliJ IDE 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
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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
Posts: 17346
11
Mac IntelliJ IDE 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
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic