open class ContentNegotiationManagerFactoryBean : FactoryBean<ContentNegotiationManager>, ServletContextAware, InitializingBean
Factory to create a ContentNegotiationManager
and configure it with one or more ContentNegotiationStrategy instances.
As of 5.0 you can set the exact strategies to use via #setStrategies(List)
.
As an alternative you can also rely on the set of defaults described below which can be turned on or off or customized through the methods of this builder:
Property Setter Underlying Strategy Default Setting#setFavorPathExtension
PathExtensionContentNegotiationStrategy On favorParameter
ParameterContentNegotiationStrategy Off ignoreAcceptHeader
HeaderContentNegotiationStrategy On defaultContentType
FixedContentNegotiationStrategy Not set defaultContentTypeStrategy
ContentNegotiationStrategy Not set 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 #setFavorPathExtension
to false or otherwise set the strategies to use explicitly via #setStrategies(List)
.
Author
Rossen Stoyanchev
Author
Brian Clozel
Since
3.2
ContentNegotiationManagerFactoryBean()
Factory to create a As of 5.0 you can set the exact strategies to use via As an alternative you can also rely on the set of defaults described below which can be turned on or off or customized through the methods of this builder: Property Setter Underlying Strategy Default Setting#setFavorPathExtension PathExtensionContentNegotiationStrategy On favorParameter ParameterContentNegotiationStrategy Off ignoreAcceptHeader HeaderContentNegotiationStrategy On defaultContentType FixedContentNegotiationStrategy Not set defaultContentTypeStrategy ContentNegotiationStrategy Not set 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 #setFavorPathExtension to false or otherwise set the strategies to use explicitly via #setStrategies(List) .
|
open fun addMediaType(fileExtension: String, mediaType: MediaType): Unit
An alternative to |
|
open fun addMediaTypes(mediaTypes: MutableMap<String, MediaType>): Unit
An alternative to |
|
open fun afterPropertiesSet(): Unit |
|
open fun build(): ContentNegotiationManager
Actually build the ContentNegotiationManager. |
|
open fun getObject(): ContentNegotiationManager |
|
open fun getObjectType(): Class<*> |
|
open fun isSingleton(): Boolean |
|
open fun setDefaultContentType(contentType: MediaType): Unit
Set the default content type to use when no content type is requested. By default this is not set. |
|
open fun setDefaultContentTypeStrategy(strategy: ContentNegotiationStrategy): Unit
Set a custom ContentNegotiationStrategy to use to determine the content type to use when no content type is requested. By default this is not set. |
|
open fun setDefaultContentTypes(contentTypes: MutableList<MediaType>): Unit
Set the default content types to use when no content type is requested. By default this is not set. |
|
open fun setFavorParameter(favorParameter: Boolean): Unit
Whether a request parameter ("format" by default) should be used to determine the requested media type. For this option to work you must register By default this is set to |
|
open fun setFavorPathExtension(favorPathExtension: Boolean): Unit
Whether the path extension in the URL path should be used to determine the requested media type. By default this is set to |
|
open fun setIgnoreAcceptHeader(ignoreAcceptHeader: Boolean): Unit
Whether to disable checking the 'Accept' request header. By default this value is set to |
|
open fun setIgnoreUnknownPathExtensions(ignore: Boolean): Unit
Whether to ignore requests with path extension that cannot be resolved to any media type. Setting this to By default this is set to |
|
open fun setMediaTypes(mediaTypes: Properties): Unit
Add a mapping from a key, extracted from a path extension or a query parameter, to a MediaType. This is required in order for the parameter strategy to work. Any extensions explicitly registered here are also whitelisted for the purpose of Reflected File Download attack detection (see Spring Framework reference documentation for more details on RFD attack protection). The path extension strategy will also try to use |
|
open fun setParameterName(parameterName: String): Unit
Set the query parameter name to use when The default parameter name is |
|
open fun setServletContext(servletContext: ServletContext): Unit
Invoked by Spring to inject the ServletContext. |
|
open fun setStrategies(strategies: MutableList<ContentNegotiationStrategy>): Unit
Set the exact list of strategies to use. Note: use of this method is mutually exclusive with use of all other setters in this class which customize a default, fixed set of strategies. See class level doc for more details. |
|
open fun setUseJaf(useJaf: Boolean): Unit |
|
open fun setUseRegisteredExtensionsOnly(useRegisteredExtensionsOnly: Boolean): Unit
When By default this is not set in which case dynamic resolution is on. |