public class ContentNegotiationConfigurer
extends java.lang.Object
ContentNegotiationManager.
By default strategies for checking the extension of the request path and
the Accept header are registered. The path extension check will perform
lookups through the ServletContext and the Java Activation Framework
(if present) unless media types are configured.
| Constructor and Description |
|---|
ContentNegotiationConfigurer() |
| Modifier and Type | Method and Description |
|---|---|
ContentNegotiationConfigurer |
addMediaType(java.lang.String extension,
MediaType mediaType)
Add mappings from file extensions to media types.
|
ContentNegotiationConfigurer |
addMediaTypes(java.util.Map<java.lang.String,MediaType> mediaTypes)
Add mappings from file extensions to media types.
|
protected ContentNegotiationManager |
getContentNegotiationManager() |
ContentNegotiationConfigurer |
replaceMediaTypes(java.util.Map<java.lang.String,MediaType> mediaTypes)
Add mappings from file extensions to media types replacing any previous mappings.
|
ContentNegotiationConfigurer |
setDefaultContentType(MediaType defaultContentType)
Set the default content type.
|
ContentNegotiationConfigurer |
setFavorParameter(boolean favorParameter)
Indicate whether a request parameter should be used to determine the
requested media type with the 2nd highest priority, i.e.
|
ContentNegotiationConfigurer |
setFavorPathExtension(boolean favorPathExtension)
Indicate whether the extension of the request path should be used to determine
the requested media type with the highest priority.
|
ContentNegotiationConfigurer |
setIgnoreAcceptHeader(boolean ignoreAcceptHeader)
Indicate whether the HTTP
Accept header should be ignored altogether. |
ContentNegotiationConfigurer |
setParameterName(java.lang.String parameterName)
Set the parameter name that can be used to determine the requested media type
if the
setFavorParameter(boolean) property is true. |
ContentNegotiationConfigurer |
setUseJaf(boolean useJaf)
Indicate whether to use the Java Activation Framework as a fallback option
to map from file extensions to media types.
|
public ContentNegotiationConfigurer setFavorPathExtension(boolean favorPathExtension)
By default this value is set to true in which case a request
for /hotels.pdf will be interpreted as a request for
"application/pdf" regardless of the Accept header.
public ContentNegotiationConfigurer addMediaType(java.lang.String extension, MediaType mediaType)
If this property is not set, the Java Action Framework, if available, may
still be used in conjunction with setFavorPathExtension(boolean).
public ContentNegotiationConfigurer addMediaTypes(java.util.Map<java.lang.String,MediaType> mediaTypes)
If this property is not set, the Java Action Framework, if available, may
still be used in conjunction with setFavorPathExtension(boolean).
public ContentNegotiationConfigurer replaceMediaTypes(java.util.Map<java.lang.String,MediaType> mediaTypes)
If this property is not set, the Java Action Framework, if available, may
still be used in conjunction with setFavorPathExtension(boolean).
public ContentNegotiationConfigurer setUseJaf(boolean useJaf)
setFavorPathExtension(boolean) is set to true.
The default value is true.
parameterName,
#setMediaTypes(Map)public ContentNegotiationConfigurer setFavorParameter(boolean favorParameter)
Accept header.
The default value is false. If set to to true, a request
for /hotels?format=pdf will be interpreted as a request for
"application/pdf" regardless of the Accept header.
To use this option effectively you must also configure the MediaType
type mappings via #setMediaTypes(Map).
setParameterName(String)public ContentNegotiationConfigurer setParameterName(java.lang.String parameterName)
setFavorParameter(boolean) property is true.
The default parameter name is "format".
public ContentNegotiationConfigurer setIgnoreAcceptHeader(boolean ignoreAcceptHeader)
Accept header should be ignored altogether.
If set the Accept header is checked at the
3rd highest priority, i.e. after the request path extension and
possibly a request parameter if configured.
By default this value is set to false.
public ContentNegotiationConfigurer setDefaultContentType(MediaType defaultContentType)
This content type will be used when neither the request path extension,
nor a request parameter, nor the Accept header could help determine
the requested content type.
protected ContentNegotiationManager getContentNegotiationManager()
ContentNegotiationManager instance