类 ContentNegotiationManager
java.lang.Object
cn.taketoday.web.accept.ContentNegotiationManager
public class ContentNegotiationManager
extends Object
implements ContentNegotiationStrategy, MediaTypeFileExtensionResolver
Central class to determine requested media types
for a request. This is done by delegating to a list of configured
ContentNegotiationStrategy instances.
Also provides methods to look up file extensions for a media type.
This is done by delegating to the list of configured
MediaTypeFileExtensionResolver instances.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Harry Yang
-
字段概要
字段修饰符和类型字段说明private final LinkedHashSet<MediaTypeFileExtensionResolver>private final ArrayList<ContentNegotiationStrategy>从接口继承的字段 cn.taketoday.web.accept.ContentNegotiationStrategy
MEDIA_TYPE_ALL_LIST -
构造器概要
构造器构造器说明Create a default instance with aHeaderContentNegotiationStrategy.ContentNegotiationManager(ContentNegotiationStrategy... strategies) Create an instance with the given list ofContentNegotiationStrategystrategies each of which may also be an instance ofMediaTypeFileExtensionResolver.A collection-based alternative toContentNegotiationManager(ContentNegotiationStrategy...). -
方法概要
修饰符和类型方法说明voidaddFileExtensionResolvers(MediaTypeFileExtensionResolver... resolvers) Register moreMediaTypeFileExtensionResolverinstances in addition to those detected at construction.doResolveExtensions(Function<MediaTypeFileExtensionResolver, List<String>> extractor) Get all registered file extensions.Return all registered lookup key to media type mappings by iteratingMediaTypeFileExtensionResolvers.Return the configured content negotiation strategies.<T extends ContentNegotiationStrategy>
TgetStrategy(Class<T> strategyType) Find aContentNegotiationStrategyof the given type.resolveFileExtensions(MediaType mediaType) Resolve the given media type to a list of file extensions.resolveMediaTypes(RequestContext request) Resolve the given request to a list of media types.
-
字段详细资料
-
strategies
-
resolvers
-
-
构造器详细资料
-
ContentNegotiationManager
Create an instance with the given list ofContentNegotiationStrategystrategies each of which may also be an instance ofMediaTypeFileExtensionResolver.- 参数:
strategies- the strategies to use
-
ContentNegotiationManager
A collection-based alternative toContentNegotiationManager(ContentNegotiationStrategy...).- 参数:
strategies- the strategies to use
-
ContentNegotiationManager
public ContentNegotiationManager()Create a default instance with aHeaderContentNegotiationStrategy.
-
-
方法详细资料
-
getStrategies
Return the configured content negotiation strategies. -
getStrategy
Find aContentNegotiationStrategyof the given type.- 参数:
strategyType- the strategy type- 返回:
- the first matching strategy, or
nullif none
-
addFileExtensionResolvers
Register moreMediaTypeFileExtensionResolverinstances in addition to those detected at construction.- 参数:
resolvers- the resolvers to add
-
resolveMediaTypes
public List<MediaType> resolveMediaTypes(RequestContext request) throws HttpMediaTypeNotAcceptableException 从接口复制的说明:ContentNegotiationStrategyResolve the given request to a list of media types. The returned list is ordered by specificity first and by quality parameter second.- 指定者:
resolveMediaTypes在接口中ContentNegotiationStrategy- 参数:
request- the current request context- 返回:
- the requested media types, or
ContentNegotiationStrategy.MEDIA_TYPE_ALL_LISTif none were requested. - 抛出:
HttpMediaTypeNotAcceptableException- if the requested media types cannot be parsed
-
resolveFileExtensions
从接口复制的说明:MediaTypeFileExtensionResolverResolve the given media type to a list of file extensions.- 指定者:
resolveFileExtensions在接口中MediaTypeFileExtensionResolver- 参数:
mediaType- the media type to resolve- 返回:
- a list of extensions or an empty list (never
null)
-
getAllFileExtensions
Get all registered file extensions.At startup this method returns extensions explicitly registered with
ParameterContentNegotiationStrategy.MediaTypeand cached.- 指定者:
getAllFileExtensions在接口中MediaTypeFileExtensionResolver- 返回:
- a list of extensions or an empty list (never
null)
-
doResolveExtensions
-
getMediaTypeMappings
Return all registered lookup key to media type mappings by iteratingMediaTypeFileExtensionResolvers.
-