Announcement Announcement Module
Collapse
No announcement yet.
Can HttpMessageConverters use file extension like ContentNegotiatingViewResolver? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can HttpMessageConverters use file extension like ContentNegotiatingViewResolver?

    Using ContentNegotiatingViewResolver it will use the requests file extension as a hint to the content type being requested, unfortunately HttpMessageConverter's do not behave the same. Is there a workaround to using behaviour? Is it planned for a future release of spring-web to add this behaviour?

    As an example, consider the following endpoint:

    http://myapp.com/api/customer/100

    I could pass a content type of "application/json" to retrieve the JSON output, or "text/xml" to retrieve it in XML, or; when using view resolvers I could simply request with the extension, i.e.

    http://myapp.com/api/customer/100.xml
    http://myapp.com/api/customer/100.json

    With message converters however, both of these requests work, however the first that matches the "Accept" header will be used. More so the accept order is not respected with message converters, i.e. "Accept: application/json, text/xml" is treated the same as "Accept: text/xml, application/json".
Working...
X