-
Notifications
You must be signed in to change notification settings - Fork 38.9k
Description
Spring Boot version 2.4.0 Also testing in spring boot 1.3.2.RELEASE
When the default content type is set to XML if a request comes in that allows a "*/*" response then a JSON response is returned.
Clarification - A header that allows a "*/*" response. For example "Accept: text/html, */*" but not the wildcard header itself, "Accept:*/*". Note that this sentence wasn't in the initial ticket.
Workaround: Add in a Jaxb2CollectionHttpMessageConverter and a Jaxb2RootElementHttpMessageConverter as the first convertors.
Problems with the workaround. This is undocumented behaviour checking the documentation of https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.html#extendMessageConverters-java.util.List- It doesn't say that the order of the convertors matter.
Either this should be documented "Order of HttpConverters matters" or there should be a different resolution strategy.
Therefore I'm concerned that the workaround may be less than stable.
It would be good to have an explicit favoured response type that is returned when there are equal priorities in content negotiation strategies.
A full application that uses this is posted to a related stackoverflow ticket https://stackoverflow.com/questions/65689179/how-do-you-configure-spring-boot-2-to-return-xml-by-default/65702088#65702088
I can send the file if required. Or zip up a project.