public class PathExtensionContentNegotiationStrategy extends AbstractMappingContentNegotiationStrategy
ServletContext.getMimeType(String)
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(java.util.Map<java.lang.String,MediaType> mediaTypes)
Create an instance with the given extension-to-MediaType lookup.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
getMediaTypeKey(NativeWebRequest webRequest)
Sub-classes must extract the key to use to look up a media type.
|
protected void |
handleMatch(java.lang.String extension,
MediaType mediaType)
Invoked when a matching media type is found in the lookup map.
|
protected MediaType |
handleNoMatch(NativeWebRequest webRequest,
java.lang.String extension)
Invoked when no matching media type is found in the lookup map.
|
void |
setUseJaf(boolean useJaf)
Indicate whether to use the Java Activation Framework to map from file extensions to media types.
|
resolveMediaTypesaddMapping, getAllFileExtensions, lookupMediaType, resolveFileExtensionsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAllFileExtensions, resolveFileExtensionspublic PathExtensionContentNegotiationStrategy(java.util.Map<java.lang.String,MediaType> mediaTypes)
java.lang.IllegalArgumentException - if a media type string cannot be parsedpublic PathExtensionContentNegotiationStrategy()
ServletContext.getMimeType(String)
or through the Java Activation framework.public void setUseJaf(boolean useJaf)
Default is true, i.e. the Java Activation Framework is used (if available).
protected java.lang.String getMediaTypeKey(NativeWebRequest webRequest)
AbstractMappingContentNegotiationStrategygetMediaTypeKey in class AbstractMappingContentNegotiationStrategynull if the key cannot be derivedprotected void handleMatch(java.lang.String extension,
MediaType mediaType)
AbstractMappingContentNegotiationStrategyhandleMatch in class AbstractMappingContentNegotiationStrategyprotected MediaType handleNoMatch(NativeWebRequest webRequest, java.lang.String extension)
AbstractMappingContentNegotiationStrategyhandleNoMatch in class AbstractMappingContentNegotiationStrategy