Announcement Announcement Module
Collapse
No announcement yet.
Using simply Accept headers to choose how to output JSON, XML, JSONP? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using simply Accept headers to choose how to output JSON, XML, JSONP?

    I'm trying to setup Spring 3.1 as a REST layer and so far things are going well. What I haven't been able to sort out is if there's a clean way to use only Accept headers to determine how to format output from a REST controller call. Most examples I find recommend using a filter and checking the request parameter "callback". I'd prefer to avoid attaching a filter to all service calls on our app. There seem to be unintended consequences to doing this.

    I would be willing to try this, however, but before I commit to that I was wondering if it wasn't possible to simply use the Accept header and if so what that application-context.xml configuration would look like. So far I've had good success getting Spring 3.1.2 + Jackson 2 to format either XML or JSON depending on the Accept header. The problem child is JSONP. Even when I add JSONP as a "MediaType" in Spring configuration it's unclear how to get that to work.
Working...
X