public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
You can register static mappings between keys (i.e. the expected value of
the query parameter) and MediaType's via MappingMediaTypeFileExtensionResolver.addMapping(String, MediaType)
.
As of 5.0 this strategy also supports dynamic lookups of keys via
MediaTypeFactory.getMediaType(org.springframework.core.io.Resource)
.
logger
MEDIA_TYPE_ALL_LIST
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() |
void |
setParameterName(java.lang.String parameterName)
Set the name of the parameter to use to determine requested media types.
|
handleMatch, handleNoMatch, isIgnoreUnknownExtensions, isUseRegisteredExtensionsOnly, resolveMediaTypeKey, resolveMediaTypes, setIgnoreUnknownExtensions, setUseRegisteredExtensionsOnly
addMapping, getAllFileExtensions, getAllMediaTypes, getMediaTypes, lookupMediaType, resolveFileExtensions
public 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()
@Nullable protected java.lang.String getMediaTypeKey(NativeWebRequest request)
AbstractMappingContentNegotiationStrategy
getMediaTypeKey
in class AbstractMappingContentNegotiationStrategy
null
if none