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 |
setUseJaf(boolean useJaf)
Indicate whether to use the Java Activation Framework to map from file extensions to media types.
|
resolveMediaTypes
addMapping, getAllFileExtensions, lookupMediaType, resolveFileExtensions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllFileExtensions, resolveFileExtensions
public 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).
protected String getMediaTypeKey(NativeWebRequest webRequest)
AbstractMappingContentNegotiationStrategy
getMediaTypeKey
in class AbstractMappingContentNegotiationStrategy
null
if the key cannot be derivedprotected void handleMatch(String extension, MediaType mediaType)
AbstractMappingContentNegotiationStrategy
handleMatch
in class AbstractMappingContentNegotiationStrategy
protected MediaType handleNoMatch(NativeWebRequest webRequest, String extension)
AbstractMappingContentNegotiationStrategy
handleNoMatch
in class AbstractMappingContentNegotiationStrategy