aspose file tools*
The moose likes Spring and the fly likes HTTP status 406 - Please HELP!!! Spring+Ajax+JSON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "HTTP status 406 - Please HELP!!! Spring+Ajax+JSON" Watch "HTTP status 406 - Please HELP!!! Spring+Ajax+JSON" New topic
Author

HTTP status 406 - Please HELP!!! Spring+Ajax+JSON

Tony Ghy
Greenhorn

Joined: Feb 12, 2011
Posts: 8
I'm facing a problem while trying to retrieve a Collection of Object (List<MyObject>) through Ajax call using Jquery.

My jsp where i make a call is :


The getCities is mapped to the following:


I believe the problem lies here: @ResponseBody is not able to automatically convert the List value into JSON format & hence i get the following error:


Please guide me.
I used Firbug to see what's going on. Here's what i get:


Please Help me. I'm stuck.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

That is because you are doing a POST. a POST in REST means you are creating a new object. You are not, you want to GET the List. So you have to do a GET in order for it to work.

In a POST, the accept header is not requesting any type/format back, the response should only have the success status set and the URI to then GET what just got created. So the Body of a POST is always empty.

a GET is the only RequestMethod type to return data in the Body.

an Update and a Delete only return the status.

Hope that helps

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HTTP status 406 - Please HELP!!! Spring+Ajax+JSON