public abstract class AbstractMappingContentNegotiationStrategy extends MappingTinyMediaTypeFileExtensionResolver implements ContentNegotiationStrategy, MediaTypeFileExtensionResolver
Constructor and Description |
---|
AbstractMappingContentNegotiationStrategy(Map<String,org.springframework.http.MediaType> mediaTypes)
Create an instance with the given extension-to-MediaType lookup.
|
Modifier and Type | Method and Description |
---|---|
protected abstract String |
getMediaTypeKey(org.springframework.web.context.request.NativeWebRequest request)
Sub-classes must extract the key to use to look up a media type.
|
protected void |
handleMatch(String mappingKey,
org.springframework.http.MediaType mediaType)
Invoked when a matching media type is found in the lookup map.
|
protected org.springframework.http.MediaType |
handleNoMatch(org.springframework.web.context.request.NativeWebRequest request,
String key)
Invoked when no matching media type is found in the lookup map.
|
List<org.springframework.http.MediaType> |
resolveMediaTypes(org.springframework.web.context.request.NativeWebRequest webRequest)
Resolve the given request to a list of media types.
|
addMapping, getAllFileExtensions, getAllMediaTypes, lookupMediaType, resolveFileExtensions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAllFileExtensions, resolveFileExtensions
public AbstractMappingContentNegotiationStrategy(Map<String,org.springframework.http.MediaType> mediaTypes)
IllegalArgumentException
- if a media type string cannot be parsedpublic List<org.springframework.http.MediaType> resolveMediaTypes(org.springframework.web.context.request.NativeWebRequest webRequest) throws org.springframework.web.HttpMediaTypeNotAcceptableException
ContentNegotiationStrategy
resolveMediaTypes
in interface ContentNegotiationStrategy
webRequest
- the current requestnull
)org.springframework.web.HttpMediaTypeNotAcceptableException
- if the requested media
types cannot be parsedprotected abstract String getMediaTypeKey(org.springframework.web.context.request.NativeWebRequest request)
null
if the key cannot be derivedprotected void handleMatch(String mappingKey, org.springframework.http.MediaType mediaType)
protected org.springframework.http.MediaType handleNoMatch(org.springframework.web.context.request.NativeWebRequest request, String key) throws org.springframework.web.HttpMediaTypeNotAcceptableException
org.springframework.web.HttpMediaTypeNotAcceptableException
Copyright © 2006–2018 TinyGroup. All rights reserved.