public class PathExtensionContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
The presence of the Java Activation framework is detected and enabled
automatically but the setUseJaf(boolean) property may be used to
override that setting.
| Constructor and Description |
|---|
PathExtensionContentNegotiationStrategy()
Create an instance without any mappings to start with.
|
PathExtensionContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
Create an instance with the given extension-to-MediaType lookup.
|
| Modifier and Type | Method and Description |
|---|---|
protected String |
getMediaTypeKey(NativeWebRequest webRequest)
Sub-classes must extract the key to use to look up a media type.
|
protected void |
handleMatch(String extension,
MediaType mediaType)
Invoked when a matching media type is found in the lookup map.
|
protected MediaType |
handleNoMatch(NativeWebRequest webRequest,
String extension)
Invoked when no matching media type is found in the lookup map.
|
void |
setIgnoreUnknownExtensions(boolean ignoreUnknownExtensions)
Whether to ignore requests that have a file extension that does not match
any mapped media types.
|
void |
setUseJaf(boolean useJaf)
Indicate whether to use the Java Activation Framework to map from file
extensions to media types.
|
resolveMediaTypeKey, resolveMediaTypesaddMapping, getAllFileExtensions, getAllMediaTypes, lookupMediaType, resolveFileExtensionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllFileExtensions, resolveFileExtensionspublic PathExtensionContentNegotiationStrategy(Map<String,MediaType> mediaTypes)
IllegalArgumentException - if a media type string cannot be parsedpublic PathExtensionContentNegotiationStrategy()
public void setUseJaf(boolean useJaf)
Default is true, i.e. the Java Activation Framework is used
(if available).
public void setIgnoreUnknownExtensions(boolean ignoreUnknownExtensions)
false will result in a
HttpMediaTypeNotAcceptableException.
By default this is set to true.
protected String getMediaTypeKey(NativeWebRequest webRequest)
AbstractMappingContentNegotiationStrategygetMediaTypeKey in class AbstractMappingContentNegotiationStrategynull if the key cannot be derivedprotected void handleMatch(String extension, MediaType mediaType)
AbstractMappingContentNegotiationStrategyhandleMatch in class AbstractMappingContentNegotiationStrategyprotected MediaType handleNoMatch(NativeWebRequest webRequest, String extension) throws HttpMediaTypeNotAcceptableException
AbstractMappingContentNegotiationStrategyhandleNoMatch in class AbstractMappingContentNegotiationStrategyHttpMediaTypeNotAcceptableException