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 inContentNegotiationManagerFactoryBean
on the deprecation of path extension config options.AContentNegotiationStrategy
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
MediaTypeFactory
is 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 MediaType
getMediaTypeForResource(Resource resource)
Deprecated.protected String
getMediaTypeKey(NativeWebRequest webRequest)
Deprecated.Extract a key from the request to use to look up media types.void
setUrlPathHelper(UrlPathHelper urlPathHelper)
Deprecated.Configure aUrlPathHelper
to use ingetMediaTypeKey(org.springframework.web.context.request.NativeWebRequest)
in order to derive the lookup path for a target request URL path.void
setUseJaf(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 aUrlPathHelper
to 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:AbstractMappingContentNegotiationStrategy
Extract a key from the request to use to look up media types.- Specified by:
getMediaTypeKey
in classAbstractMappingContentNegotiationStrategy
- Returns:
- the lookup key, or
null
if 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 aMediaType
in this case for a givenResource
. The method first looks up any explicitly registered file extensions first and then falls back onMediaTypeFactory
if available.- Parameters:
resource
- the resource to look up- Returns:
- the MediaType for the extension, or
null
if none found - Since:
- 4.3