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 in `ContentNegotiationManagerFactoryBean` on the deprecation of path extension config options.
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 `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

Modifier and Type
Method
Description
`MediaType`
`getMediaTypeForResource(org.springframework.core.io.Resource resource)`
Deprecated.
A public method exposing the knowledge of the path extension strategy to resolve file extensions to a `MediaType` in this case for a given `Resource`.
`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 a `UrlPathHelper` to use in `getMediaTypeKey(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 of `AbstractMappingContentNegotiationStrategy.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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### 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 Details

### setUrlPathHelper

public void setUrlPathHelper(UrlPathHelper urlPathHelper)
Deprecated.
Configure a `UrlPathHelper` to use in `getMediaTypeKey(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 of `AbstractMappingContentNegotiationStrategy.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 class `AbstractMappingContentNegotiationStrategy`
Returns:
  the lookup key, or `null` if none

### getMediaTypeForResource

@Nullable public MediaType getMediaTypeForResource(org.springframework.core.io.Resource resource)
Deprecated.
A public method exposing the knowledge of the path extension strategy to resolve file extensions to a `MediaType` in this case for a given `Resource`. The method first looks up any explicitly registered file extensions first and then falls back on `MediaTypeFactory` if available.

Parameters:
  `resource` - the resource to look up
Returns:
  the MediaType for the extension, or `null` if none found
Since:
  4.3