public class ServletPathExtensionContentNegotiationStrategy extends PathExtensionContentNegotiationStrategy
PathExtensionContentNegotiationStrategy
that also uses
ServletContext#getMimeType(String)
to resolve file extensions.Modifier and Type | Field and Description |
---|---|
private ServletContext |
servletContext |
Constructor and Description |
---|
ServletPathExtensionContentNegotiationStrategy(ServletContext context)
Create an instance without any mappings to start with.
|
ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext,
java.util.Map<java.lang.String,MediaType> mediaTypes)
Create an instance with the given extension-to-MediaType lookup.
|
Modifier and Type | Method and Description |
---|---|
MediaType |
getMediaTypeForResource(Resource resource)
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,
java.lang.String extension)
Resolve file extension via
ServletContext#getMimeType(String)
and also delegate to base class for a potential JAF lookup. |
getMediaTypeKey, setIgnoreUnknownExtensions, setUrlPathHelper, setUseJaf
handleMatch, resolveMediaTypeKey, resolveMediaTypes
addMapping, getAllFileExtensions, getAllMediaTypes, getMediaTypes, lookupMediaType, resolveFileExtensions
public ServletPathExtensionContentNegotiationStrategy(ServletContext servletContext, java.util.Map<java.lang.String,MediaType> mediaTypes)
public ServletPathExtensionContentNegotiationStrategy(ServletContext context)
ServletContext#getMimeType(String)
or via JAF.protected MediaType handleNoMatch(NativeWebRequest webRequest, java.lang.String extension) throws HttpMediaTypeNotAcceptableException
ServletContext#getMimeType(String)
and also delegate to base class for a potential JAF lookup.handleNoMatch
in class PathExtensionContentNegotiationStrategy
HttpMediaTypeNotAcceptableException
public MediaType getMediaTypeForResource(Resource resource)
PathExtensionContentNegotiationStrategy.getMediaTypeForResource(org.springframework.core.io.Resource)
with the ability to also look up through the ServletContext.getMediaTypeForResource
in class PathExtensionContentNegotiationStrategy
resource
- the resource to look upnull
.