• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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
 
permaculture is largely about replacing oil with people. And one tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic