This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Spring and the fly likes REST web service return both XML or JSON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "REST web service return both XML or JSON" Watch "REST web service return both XML or JSON" New topic
Author

REST web service return both XML or JSON

Brian Moeller
Greenhorn

Joined: Feb 04, 2011
Posts: 1
I am trying to have a REST web service return both XML or JSON depending on the extension on the url (.xml .json).
As it is now it will ONLY return JSON no matter the extension.

Here is the method:


Here is my servlet-context.xml:



What am I doing wrong?
Thanks in advance for the help.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17276
    
    6

I think, but you need to check the documentation that to get that affect, you need to configure the ContentNegotiatingViewResolver instead of using <mvc:annoation-drive/>

Mark


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: REST web service return both XML or JSON
 
It's not a secret anymore!