类 ParameterContentNegotiationStrategy
- java.lang.Object
- org.springframework.web.accept.MappingMediaTypeFileExtensionResolver
- org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
- org.springframework.web.accept.ParameterContentNegotiationStrategy
public class ParameterContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
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
MappingMediaTypeFileExtensionResolver.addMapping(String, MediaType)
. As of 5.0 this strategy also supports dynamic lookups of keys viaMediaTypeFactory.getMediaType(org.springframework.core.io.Resource)
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev
字段概要
从类继承的字段 org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
logger
从接口继承的字段 org.springframework.web.accept.ContentNegotiationStrategy
MEDIA_TYPE_ALL_LIST
构造器概要
构造器 构造器 说明 ParameterContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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.从类继承的方法 org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
handleMatch, handleNoMatch, isIgnoreUnknownExtensions, isUseRegisteredExtensionsOnly, resolveMediaTypeKey, resolveMediaTypes, setIgnoreUnknownExtensions, setUseRegisteredExtensionsOnly
从类继承的方法 org.springframework.web.accept.MappingMediaTypeFileExtensionResolver
addMapping, getAllFileExtensions, getAllMediaTypes, getMediaTypes, lookupMediaType, resolveFileExtensions
构造器详细资料
ParameterContentNegotiationStrategy
public ParameterContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types.
方法详细资料
setParameterName
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"
.
getParameterName
public String getParameterName()
getMediaTypeKey
@Nullable protected String getMediaTypeKey(NativeWebRequest request)
Extract a key from the request to use to look up media types.- 指定者:
getMediaTypeKey
在类中AbstractMappingContentNegotiationStrategy
- 返回:
- the lookup key, or
null
if none