public class ContentNegotiationManager extends Object implements ContentNegotiationStrategy, MediaTypeFileExtensionResolver
Constructor and Description |
---|
ContentNegotiationManager()
Create a default instance with a
HeaderContentNegotiationStrategy
. |
ContentNegotiationManager(Collection<ContentNegotiationStrategy> strategies)
Create an instance with the given ContentNegotiationStrategy instances.
|
ContentNegotiationManager(ContentNegotiationStrategy... strategies)
Create an instance with the given ContentNegotiationStrategy instances.
|
Modifier and Type | Method and Description |
---|---|
void |
addFileExtensionResolvers(MediaTypeFileExtensionResolver... resolvers)
Add MediaTypeFileExtensionResolver instances.
|
List<String> |
getAllFileExtensions()
Delegate to all configured MediaTypeFileExtensionResolver instances and
aggregate the list of all known file extensions.
|
List<String> |
resolveFileExtensions(org.springframework.http.MediaType mediaType)
Delegate to all configured MediaTypeFileExtensionResolver instances and
aggregate the list of all file extensions found.
|
List<org.springframework.http.MediaType> |
resolveMediaTypes(org.springframework.web.context.request.NativeWebRequest webRequest)
Delegate to all configured ContentNegotiationStrategy instances until one
returns a non-empty list.
|
public ContentNegotiationManager(ContentNegotiationStrategy... strategies)
Each instance is checked to see if it is also an implementation of MediaTypeFileExtensionResolver, and if so it is registered as such.
strategies
- one more more ContentNegotiationStrategy instancespublic ContentNegotiationManager(Collection<ContentNegotiationStrategy> strategies)
Each instance is checked to see if it is also an implementation of MediaTypeFileExtensionResolver, and if so it is registered as such.
strategies
- one more more ContentNegotiationStrategy instancespublic ContentNegotiationManager()
HeaderContentNegotiationStrategy
.public void addFileExtensionResolvers(MediaTypeFileExtensionResolver... resolvers)
Note that some ContentNegotiationStrategy
implementations also
implement MediaTypeFileExtensionResolver
and the class
constructor accepting the former will also detect implementations of the
latter. Therefore you only need to use this method to register additional
instances.
resolvers
- one or more resolverspublic List<org.springframework.http.MediaType> resolveMediaTypes(org.springframework.web.context.request.NativeWebRequest webRequest) throws org.springframework.web.HttpMediaTypeNotAcceptableException
resolveMediaTypes
in interface ContentNegotiationStrategy
webRequest
- the current requestnull
org.springframework.web.HttpMediaTypeNotAcceptableException
- if the requested media types cannot be parsedpublic List<String> resolveFileExtensions(org.springframework.http.MediaType mediaType)
resolveFileExtensions
in interface MediaTypeFileExtensionResolver
mediaType
- the media type to resolvenull
)public List<String> getAllFileExtensions()
getAllFileExtensions
in interface MediaTypeFileExtensionResolver
null
)Copyright © 2006–2018 TinyGroup. All rights reserved.