• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
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
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic