Per-Controller MessageConverter [SPR-7213] #11872
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Tyler Vallillee opened SPR-7213 and commented
I would like to know whether there is a way to specify the order of message converters on a per-controller basis.
For example, let's assume I have the following POJO:
And I have the following controllers. First, a controller whose clients expect XML to be returned:
and now a controller whose clients expect JSON back:
Now in my servlet.xml file, I have the following to handle
@ResponseBody
marshalling:The limitation here is that, given a HTTP request with an "Accept: *" header (as is typical from most web browsers) the data from MyJsonController will always be returned as XML as the XML marshaller is the first listed messageConverter for the AnnotationMethodHandlerAdapter.
Is there a way I can specify a different ordered messageConverter list that the JsonController could reference?
I am aware of ContentNegotiatingViewResolver, however in my case the API paths are legacy and difficult to update.
It would be ideal if my controller could give a hint to the MessageConverter it prefers, or if it could have its own preferred list of MessageConverters
Affects: 3.0.2
Reference URL: http://forum.springsource.org/showthread.php?p=299622
The text was updated successfully, but these errors were encountered: