Top Description Fields Constructors Methods
org.springframework.web.accept

public Class ParameterContentNegotiationStrategy

extends AbstractMappingContentNegotiationStrategy
Class Inheritance
Imports
java.util.Map, org.springframework.http.MediaType, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.context.request.NativeWebRequest

Strategy that resolves the requested content type from a query parameter. The default query parameter name is "format".

You can register static mappings between keys (i.e. the expected value of the query parameter) and MediaType's via addMapping(String, MediaType). As of 5.0 this strategy also supports dynamic lookups of keys via org.springframework.http.MediaTypeFactory#getMediaType.

Author
Rossen Stoyanchev
Since
3.2

Field Summary

Modifier and TypeField and Description
private String
Inherited from org.springframework.web.accept.AbstractMappingContentNegotiationStrategy:
logger

Constructor Summary

AccessConstructor and Description
public
ParameterContentNegotiationStrategy(Map<String, MediaType> mediaTypes)

Create an instance with the given map of file extensions and media types.

Method Summary

Modifier and TypeMethod and Description
protected String
getMediaTypeKey(NativeWebRequest request)

Implements abstract org.springframework.web.accept.AbstractMappingContentNegotiationStrategy.getMediaTypeKey.

Extract a key from the request to use to look up media types.

public String
public void
setParameterName(String parameterName)

Set the name of the parameter to use to determine requested media types.

Inherited from org.springframework.web.accept.AbstractMappingContentNegotiationStrategy:
handleMatchhandleNoMatchisIgnoreUnknownExtensionsisUseRegisteredExtensionsOnlyresolveMediaTypeKeyresolveMediaTypessetIgnoreUnknownExtensionssetUseRegisteredExtensionsOnly

Field Detail

parameterNameback to summary
private String parameterName

Constructor Detail

ParameterContentNegotiationStrategyback to summary
public ParameterContentNegotiationStrategy(Map<String, MediaType> mediaTypes)

Create an instance with the given map of file extensions and media types.

Method Detail

getMediaTypeKeyback to summary
protected String getMediaTypeKey(NativeWebRequest request)

Implements abstract org.springframework.web.accept.AbstractMappingContentNegotiationStrategy.getMediaTypeKey.

Doc from org.springframework.web.accept.AbstractMappingContentNegotiationStrategy.getMediaTypeKey.

Extract a key from the request to use to look up media types.

Returns:String

the lookup key, or null if none

Annotations
@Override
@Nullable
getParameterNameback to summary
public String getParameterName()
setParameterNameback to summary
public void setParameterName(String parameterName)

Set the name of the parameter to use to determine requested media types.

By default this is set to "format".