Class ContentNegotiationConfigurer

java.lang.Object
org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer

public class ContentNegotiationConfigurer extends Object
Creates a ContentNegotiationManager and configures it with one or more ContentNegotiationStrategy instances.

This factory offers properties that in turn result in configuring the underlying strategies. The table below shows the property names, their default settings, as well as the strategies that they help to configure:

Property Setter Default Value Underlying Strategy Enabled Or Not
favorParameter(boolean) false ParameterContentNegotiationStrategy Off
favorPathExtension(boolean) false (as of 5.3) PathExtensionContentNegotiationStrategy Off
ignoreAcceptHeader(boolean) false HeaderContentNegotiationStrategy Enabled
defaultContentType(org.springframework.http.MediaType...) null FixedContentNegotiationStrategy Off
defaultContentTypeStrategy(org.springframework.web.accept.ContentNegotiationStrategy) null ContentNegotiationStrategy Off

As of 5.0 you can set the exact strategies to use via strategies(List).

Note: if you must use URL-based content type resolution, the use of a query parameter is simpler and preferable to the use of a path extension since the latter can cause issues with URI variables, path parameters, and URI decoding. Consider setting favorPathExtension(boolean) to false or otherwise set the strategies to use explicitly via strategies(List).

Since:
3.2
Author:
Rossen Stoyanchev