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(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.
|
Modifier and Type | Method and Description |
---|---|
protected String |
getMediaTypeKey(NativeWebRequest request)
Extract a key from the request to use to look up media types.
|
String |
getParameterName() |
void |
setParameterName(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 void setParameterName(String parameterName)
By default this is set to "format"
.
public String getParameterName()
@Nullable protected String getMediaTypeKey(NativeWebRequest request)
AbstractMappingContentNegotiationStrategy
getMediaTypeKey
in class AbstractMappingContentNegotiationStrategy
null
if none