ContentNegotiationStrategy implementations with the
steps to resolve a request to media types.
First a key (e.g. "json", "pdf") must be extracted from the request (e.g.
file extension, query param). The key must then be resolved to media type(s)
through the base class MappingMediaTypeFileExtensionResolver which
stores such mappings.
The method handleNoMatch allow subclasses to plug in additional
ways of looking up media types (e.g. through the Java Activation framework,
or jakarta.). Media types resolved
via base classes are then added to the base class
MappingMediaTypeFileExtensionResolver, i.e. cached for new lookups.
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| protected final Log | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | AbstractMappingContentNegotiationStrategy(Map<String, MediaType> mediaTypes)
Create an instance with the given map of file extensions and media types. |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract String | Returns: the lookup key, ornull if noneExtract a key from the request to use to look up media types. |
| protected void | handleMatch(String key, MediaType mediaType)
Override to provide handling when a key is successfully resolved via
|
| protected MediaType | handleNoMatch(NativeWebRequest request, String key)
Override to provide handling when a key is not resolved via. |
| public boolean | |
| public boolean | |
| public List | resolveMediaTypeKey(NativeWebRequest webRequest, String key)
An alternative to |
| public List | resolveMediaTypes(NativeWebRequest
the current request webRequest)Implements org. |
| public void | setIgnoreUnknownExtensions(boolean ignoreUnknownExtensions)
Whether to ignore requests with unknown file extension. |
| public void | setUseRegisteredExtensionsOnly(boolean useRegisteredExtensionsOnly)
Whether to only use the registered mappings to look up file extensions,
or also to use dynamic resolution (e.g. via |
| ignoreUnknownExtensions | back to summary |
|---|---|
| private boolean ignoreUnknownExtensions | |
| logger | back to summary |
|---|---|
| protected final Log logger | |
| useRegisteredExtensionsOnly | back to summary |
|---|---|
| private boolean useRegisteredExtensionsOnly | |
| AbstractMappingContentNegotiationStrategy | back to summary |
|---|---|
| public AbstractMappingContentNegotiationStrategy(Map<String, MediaType> mediaTypes) Create an instance with the given map of file extensions and media types. | |
| getMediaTypeKey | back to summary |
|---|---|
| protected abstract String getMediaTypeKey(NativeWebRequest request) Extract a key from the request to use to look up media types. | |
| handleMatch | back to summary |
|---|---|
| protected void handleMatch(String key, MediaType mediaType) Override to provide handling when a key is successfully resolved via
| |
| handleNoMatch | back to summary |
|---|---|
| protected MediaType handleNoMatch(NativeWebRequest request, String key) throws HttpMediaTypeNotAcceptableException Override to provide handling when a key is not resolved via.
| |
| isIgnoreUnknownExtensions | back to summary |
|---|---|
| public boolean isIgnoreUnknownExtensions() | |
| isUseRegisteredExtensionsOnly | back to summary |
|---|---|
| public boolean isUseRegisteredExtensionsOnly() | |
| resolveMediaTypeKey | back to summary |
|---|---|
| public List An alternative to
| |
| resolveMediaTypes | back to summary |
|---|---|
| public List Implements org. Doc from org. Resolve the given request to a list of media types. The returned list is ordered by specificity first and by quality parameter second.
| |
| setIgnoreUnknownExtensions | back to summary |
|---|---|
| public void setIgnoreUnknownExtensions(boolean ignoreUnknownExtensions) Whether to ignore requests with unknown file extension. Setting this to
By default this is set to false but is overridden in
| |
| setUseRegisteredExtensionsOnly | back to summary |
|---|---|
| public void setUseRegisteredExtensionsOnly(boolean useRegisteredExtensionsOnly) Whether to only use the registered mappings to look up file extensions,
or also to use dynamic resolution (e.g. via By default this is set to | |