Package org.springframework.web.accept

# Class ServletPathExtensionContentNegotiationStrategy

java.lang.Object
org.springframework.web.accept.MappingMediaTypeFileExtensionResolver
org.springframework.web.accept.AbstractMappingContentNegotiationStrategy
org.springframework.web.accept.PathExtensionContentNegotiationStrategy
org.springframework.web.accept.ServletPathExtensionContentNegotiationStrategy

All Implemented Interfaces:
  `ContentNegotiationStrategy`, `MediaTypeFileExtensionResolver`

@Deprecated public class ServletPathExtensionContentNegotiationStrategy extends PathExtensionContentNegotiationStrategy
Deprecated.
as of 5.2.4. See class-level note in `ContentNegotiationManagerFactoryBean` on the deprecation of path extension config options.
Extends `PathExtensionContentNegotiationStrategy` that also uses `ServletContext.getMimeType(String)` to resolve file extensions.

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
`ServletPathExtensionContentNegotiationStrategy(ServletContext context)`
Deprecated.
Create an instance without any mappings to start with.
`ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext, Map<String,MediaType> mediaTypes)`
Deprecated.
Create an instance with the given extension-to-MediaType lookup.

## Method Summary

Modifier and Type
Method
Description
`MediaType`
`getMediaTypeForResource(org.springframework.core.io.Resource resource)`
Deprecated.
Extends the base class `PathExtensionContentNegotiationStrategy.getMediaTypeForResource(org.springframework.core.io.Resource)` with the ability to also look up through the ServletContext.
`protected MediaType`
`handleNoMatch(NativeWebRequest webRequest, String extension)`
Deprecated.
Resolve file extension via `ServletContext.getMimeType(String)` and also delegate to base class for a potential `MediaTypeFactory` lookup.

### Methods inherited from class org.springframework.web.accept.PathExtensionContentNegotiationStrategy

`getMediaTypeKey, setUrlPathHelper, setUseJaf`

### Methods inherited from class org.springframework.web.accept.AbstractMappingContentNegotiationStrategy

`handleMatch, 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

### ServletPathExtensionContentNegotiationStrategy

public ServletPathExtensionContentNegotiationStrategy(ServletContext context)
Deprecated.
Create an instance without any mappings to start with. Mappings may be added later when extensions are resolved through `ServletContext.getMimeType(String)` or via `MediaTypeFactory`.

### ServletPathExtensionContentNegotiationStrategy

public ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext, @Nullable Map<String,MediaType> mediaTypes)
Deprecated.
Create an instance with the given extension-to-MediaType lookup.

## Method Details

### handleNoMatch

@Nullable protected MediaType handleNoMatch(NativeWebRequest webRequest, String extension) throws HttpMediaTypeNotAcceptableException
Deprecated.
Resolve file extension via `ServletContext.getMimeType(String)` and also delegate to base class for a potential `MediaTypeFactory` lookup.

Overrides:
  `handleNoMatch` in class `AbstractMappingContentNegotiationStrategy`
Throws:
  `HttpMediaTypeNotAcceptableException`

### getMediaTypeForResource

@Nullable public MediaType getMediaTypeForResource(org.springframework.core.io.Resource resource)
Deprecated.
Extends the base class `PathExtensionContentNegotiationStrategy.getMediaTypeForResource(org.springframework.core.io.Resource)` with the ability to also look up through the ServletContext.

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