Package org.springframework.web.accept
Class PathExtensionContentNegotiationStrategy
- java.lang.Object
- org.springframework.web.accept.MappingMediaTypeFileExtensionResolver
- org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
- org.springframework.web.accept.PathExtensionContentNegotiationStrategy
- All Implemented Interfaces:
ContentNegotiationStrategy,MediaTypeFileExtensionResolver
- Direct Known Subclasses:
ServletPathExtensionContentNegotiationStrategy
@Deprecated public class PathExtensionContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
Deprecated.as of 5.2.4. See class-level note inContentNegotiationManagerFactoryBeanon the deprecation of path extension config options.AContentNegotiationStrategythat 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
MediaTypeFactoryis used as a fallback mechanism.- Since:
- 3.2
- Author:
- Rossen Stoyanchev
Field Summary
Fields inherited from class org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
logger
Fields inherited from interface org.springframework.web.accept.ContentNegotiationStrategy
MEDIA_TYPE_ALL_LIST
Constructor Summary
Constructors Constructor Description PathExtensionContentNegotiationStrategy()Deprecated.Create an instance without any mappings to start with.PathExtensionContentNegotiationStrategy(Map<String,MediaType> mediaTypes)Deprecated.Create an instance with the given map of file extensions and media types.
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description MediaTypegetMediaTypeForResource(Resource resource)Deprecated.protected StringgetMediaTypeKey(NativeWebRequest webRequest)Deprecated.Extract a key from the request to use to look up media types.voidsetUrlPathHelper(UrlPathHelper urlPathHelper)Deprecated.Configure aUrlPathHelperto use ingetMediaTypeKey(org.springframework.web.context.request.NativeWebRequest)in order to derive the lookup path for a target request URL path.voidsetUseJaf(boolean useJaf)Deprecated.as of 5.0, in favor ofAbstractMappingContentNegotiationStrategy.setUseRegisteredExtensionsOnly(boolean).Methods inherited from class org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
handleMatch, handleNoMatch, isIgnoreUnknownExtensions, isUseRegisteredExtensionsOnly, resolveMediaTypeKey, resolveMediaTypes, setIgnoreUnknownExtensions, setUseRegisteredExtensionsOnly
Methods inherited from class org.springframework.web.accept.MappingMediaTypeFileExtensionResolver
addMapping, getAllFileExtensions, getAllMediaTypes, getMediaTypes, lookupMediaType, resolveFileExtensions
Constructor Detail
PathExtensionContentNegotiationStrategy
public PathExtensionContentNegotiationStrategy()
Deprecated.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
public PathExtensionContentNegotiationStrategy(@Nullable Map<String,MediaType> mediaTypes)
Deprecated.Create an instance with the given map of file extensions and media types.
Method Detail
setUrlPathHelper
public void setUrlPathHelper(UrlPathHelper urlPathHelper)
Deprecated.Configure aUrlPathHelperto use ingetMediaTypeKey(org.springframework.web.context.request.NativeWebRequest)in order to derive the lookup path for a target request URL path.- Since:
- 4.2.8
setUseJaf
@Deprecated public void setUseJaf(boolean useJaf)
Deprecated.as of 5.0, in favor ofAbstractMappingContentNegotiationStrategy.setUseRegisteredExtensionsOnly(boolean).Indicate whether to use the Java Activation Framework as a fallback option to map from file extensions to media types.
getMediaTypeKey
@Nullable protected String getMediaTypeKey(NativeWebRequest webRequest)
Deprecated.Description copied from class:AbstractMappingContentNegotiationStrategyExtract a key from the request to use to look up media types.- Specified by:
getMediaTypeKeyin classAbstractMappingContentNegotiationStrategy- Returns:
- the lookup key, or
nullif none
getMediaTypeForResource
@Nullable public MediaType getMediaTypeForResource(Resource resource)
Deprecated.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 onMediaTypeFactoryif available.- Parameters:
resource- the resource to look up- Returns:
- the MediaType for the extension, or
nullif none found - Since:
- 4.3