public class ContentNegotiationManager extends Object implements ContentNegotiationStrategy, MediaTypeFileExtensionResolver
HeaderContentNegotiationStrategywill be configured by default.
This class may also be used to look up file extensions associated with a
MediaType. This is done by consulting the list of configured
MediaTypeFileExtensionResolver instances. Note that some
ContentNegotiationStrategy implementations also implement
MediaTypeFileExtensionResolver and the class constructor accepting the former
will also detect if they implement the latter. If you need to register additional
resolvers, you can use the method
|Constructor and Description|
Create an instance with a
Create an instance with the given ContentNegotiationStrategy instances.
|Modifier and Type||Method and Description|
Add MediaTypeFileExtensionResolver instances.
Delegate to all configured MediaTypeFileExtensionResolver instances and aggregate the list of all known file extensions.
Delegate to all configured MediaTypeFileExtensionResolver instances and aggregate the list of all file extensions found.
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 instances
public void addFileExtensionResolvers(MediaTypeFileExtensionResolver... resolvers)
Note that some
ContentNegotiationStrategy implementations also
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 resolvers
public List<MediaType> resolveMediaTypes(NativeWebRequest webRequest) throws HttpMediaTypeNotAcceptableException
webRequest- the current request
HttpMediaTypeNotAcceptableException- if the requested media types cannot be parsed
public List<String> resolveFileExtensions(MediaType mediaType)
mediaType- the media type to resolve
public List<String> getAllFileExtensions()