public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
ContentNegotiationStrategy that resolves a query parameter to a key
to be used to look up a media type. The default parameter name is format.| Constructor and Description |
|---|
ParameterContentNegotiationStrategy(java.util.Map<java.lang.String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
getMediaTypeKey(NativeWebRequest request)
Extract a key from the request to use to look up media types.
|
java.lang.String |
getParameterName() |
protected void |
handleMatch(java.lang.String mediaTypeKey,
MediaType mediaType)
Override to provide handling when a key is successfully resolved via
MappingMediaTypeFileExtensionResolver.lookupMediaType(java.lang.String). |
protected MediaType |
handleNoMatch(NativeWebRequest request,
java.lang.String key)
Override to provide handling when a key is not resolved via.
|
void |
setParameterName(java.lang.String parameterName)
Set the name of the parameter to use to determine requested media types.
|
resolveMediaTypeKey, resolveMediaTypesaddMapping, getAllFileExtensions, getAllMediaTypes, getMediaTypes, lookupMediaType, resolveFileExtensionspublic ParameterContentNegotiationStrategy(java.util.Map<java.lang.String,MediaType> mediaTypes)
public void setParameterName(java.lang.String parameterName)
By default this is set to "format".
public java.lang.String getParameterName()
protected java.lang.String getMediaTypeKey(NativeWebRequest request)
AbstractMappingContentNegotiationStrategygetMediaTypeKey in class AbstractMappingContentNegotiationStrategynull if noneprotected void handleMatch(java.lang.String mediaTypeKey,
MediaType mediaType)
AbstractMappingContentNegotiationStrategyMappingMediaTypeFileExtensionResolver.lookupMediaType(java.lang.String).handleMatch in class AbstractMappingContentNegotiationStrategyprotected MediaType handleNoMatch(NativeWebRequest request, java.lang.String key) throws HttpMediaTypeNotAcceptableException
AbstractMappingContentNegotiationStrategyMappingMediaTypeFileExtensionResolver.lookupMediaType(java.lang.String). Sub-classes can take further steps to
determine the media type(s). If a MediaType is returned from
this method it will be added to the cache in the base class.handleNoMatch in class AbstractMappingContentNegotiationStrategyHttpMediaTypeNotAcceptableException