类 PathExtensionContentNegotiationStrategy
java.lang.Object
cn.taketoday.web.accept.MappingMediaTypeFileExtensionResolver
cn.taketoday.web.accept.AbstractMappingContentNegotiationStrategy
cn.taketoday.web.accept.PathExtensionContentNegotiationStrategy
public class PathExtensionContentNegotiationStrategy
extends AbstractMappingContentNegotiationStrategy
A
ContentNegotiationStrategy that resolves the file extension in the
request path to a key to be used to look up a media type.
If the file extension is not found in the explicit registrations provided
to the constructor, the MediaType.fromFileName(String) is used as a fallback
mechanism.
- 从以下版本开始:
- 4.0 2022/2/7 13:59
- 作者:
- Rossen Stoyanchev, Harry Yang
-
嵌套类概要
嵌套类 -
字段概要
字段从接口继承的字段 cn.taketoday.web.accept.ContentNegotiationStrategy
MEDIA_TYPE_ALL_LIST -
构造器概要
构造器构造器说明Create an instance without any mappings to start with.PathExtensionContentNegotiationStrategy(Object servletContext, Map<String, MediaType> mediaTypes) Create an instance with the given map of file extensions and media types.PathExtensionContentNegotiationStrategy(Map<String, MediaType> mediaTypes) Create an instance with the given map of file extensions and media types. -
方法概要
修饰符和类型方法说明(专用程序包) static voidassertServletContext(Object servletContext) getMediaTypeForResource(cn.taketoday.core.io.Resource resource) A public method exposing the knowledge of the path extension strategy to resolve file extensions to aMediaTypein this case for a givenResource.protected StringgetMediaTypeKey(RequestContext request) Extract a key from the request to use to look up media types.protected MediaTypehandleNoMatch(RequestContext request, String extension) Resolve file extension viaServletContext.getMimeType(String)and also delegate to base class for a potentialMediaTypeFactorylookup.从类继承的方法 cn.taketoday.web.accept.AbstractMappingContentNegotiationStrategy
handleMatch, isIgnoreUnknownExtensions, isUseRegisteredExtensionsOnly, resolveMediaTypeKey, resolveMediaTypes, setIgnoreUnknownExtensions, setUseRegisteredExtensionsOnly从类继承的方法 cn.taketoday.web.accept.MappingMediaTypeFileExtensionResolver
addMapping, getAllFileExtensions, getAllMediaTypes, getMediaTypes, lookupMediaType, resolveFileExtensions
-
字段详细资料
-
servletContext
-
-
构造器详细资料
-
PathExtensionContentNegotiationStrategy
public PathExtensionContentNegotiationStrategy()Create an instance without any mappings to start with. Mappings may be added later on if any extensions are resolved through the Java Activation framework. -
PathExtensionContentNegotiationStrategy
Create an instance with the given map of file extensions and media types. -
PathExtensionContentNegotiationStrategy
public PathExtensionContentNegotiationStrategy(@Nullable Object servletContext, @Nullable Map<String, MediaType> mediaTypes) Create an instance with the given map of file extensions and media types.
-
-
方法详细资料
-
assertServletContext
-
getMediaTypeKey
Extract a key from the request to use to look up media types.- 指定者:
getMediaTypeKey在类中AbstractMappingContentNegotiationStrategy- 返回:
- the lookup key, or
nullif none
-
handleNoMatch
@Nullable protected MediaType handleNoMatch(RequestContext request, String extension) throws HttpMediaTypeNotAcceptableException Resolve file extension viaServletContext.getMimeType(String)and also delegate to base class for a potentialMediaTypeFactorylookup. -
getMediaTypeForResource
A public method exposing the knowledge of the path extension strategy to resolve file extensions to aMediaTypein this case for a givenResource. The method first looks up any explicitly registered file extensions first and then falls back onMediaType.fromFileName(String)if available.- 参数:
resource- the resource to look up- 返回:
- the MediaType for the extension, or
nullif none found
-