Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Spring
406 when trying to resolve xml
John Eric Hamacher
Ranch Hand
Posts: 230
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hello:
My REST service looks like this:
@RequestMapping(value="/get/{district}/{wsn}", method=RequestMethod.GET, headers={"Accept=text/xml"}) public @ResponseBody LookupResult lookup(@PathVariable String wsn, @PathVariable String district) { System.err.println(wsn= " + wsn + " district = " + district); LookupResult lr = new LookupResult(true); return lr; }
I send the following URL:
http://localhost::9081/contextroot/SIMS/get/2828/1234567890.xml
which has an Accept header of "text/xml"
My view resolver looks like:
<bean class= "org.springframework.web.servlet.view.ContentNegotiatingViewResolver"> <property name="mediaTypes"> <map> <entry key="xml" value="text/xml" /> </map> </property> <property name="defaultContentType" value="text/xml" /> </bean>
I get a 406 response. I've tried to make it as explicit as possible that I want XML returned. Does anybody spot a problem?
THanks
Eric
Paul Clapham
Marshal
Posts: 28193
95
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
When I googled for the HTTP Accept header, the link I found (from Wikipedia) suggested it should look like "Accept: text/xml". Yours doesn't quite look like that.
John Eric Hamacher
Ranch Hand
Posts: 230
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks, all I needed to do is use JAXB annotations in the object I wanted to convert.
eric
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
selectOneMenu to a managed bean
ContentNegotiatingViewResolver
Automatic Schema Generation
Spring + JPA + Hibernate and multiple Database connection
trouble parsing stream or string into xml
More...