This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 17249
    
    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 - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
wood burning stoves
 
subject: REST web service return both XML or JSON
 
Similar Threads
javax.servlet.ServletException: No adapter for handler
STS springMVC project how to run on tomcat application
Spring LDAP/Active Directory Security: Authenticate User w/out Using an Admin/Mgr Account
spring security 3.1 login not working.
javax.servlet.ServletException: Could not resolve view with name home-- apache Velocity, spring