public class EncodedResourceResolver extends AbstractResourceResolver
The list of supported contentCodings can
be configured, in order of preference, and each coding must be associated
with extensions.
Note that this resolver must be ordered ahead of a
VersionResourceResolver with a content-based, version strategy to
ensure the version calculation is not impacted by the encoding.
| Modifier and Type | Field and Description |
|---|---|
static List<String> |
DEFAULT_CODINGS
The default content codings.
|
logger| Constructor and Description |
|---|
EncodedResourceResolver() |
| Modifier and Type | Method and Description |
|---|---|
List<String> |
getContentCodings()
Return a read-only list with the supported content codings.
|
Map<String,String> |
getExtensions()
Return a read-only map with coding-to-extension mappings.
|
void |
registerExtension(String coding,
String extension)
Java config friendly alternative to
setExtensions(Map). |
protected Resource |
resolveResourceInternal(HttpServletRequest request,
String requestPath,
List<? extends Resource> locations,
ResourceResolverChain chain) |
protected String |
resolveUrlPathInternal(String resourceUrlPath,
List<? extends Resource> locations,
ResourceResolverChain chain) |
void |
setContentCodings(List<String> codings)
Configure the supported content codings in order of preference.
|
void |
setExtensions(Map<String,String> extensions)
Configure mappings from content codings to file extensions.
|
resolveResource, resolveUrlPathpublic void setContentCodings(List<String> codings)
Note: Each coding must be associated with a file
extension via registerExtension(java.lang.String, java.lang.String) or setExtensions(java.util.Map<java.lang.String, java.lang.String>). Also
customizations to the list of codings here should be matched by
customizations to the same list in CachingResourceResolver to
ensure encoded variants of a resource are cached under separate keys.
By default this property is set to ["br", "gzip"].
codings - one or more supported content codingspublic List<String> getContentCodings()
public void setExtensions(Map<String,String> extensions)
By default this is configured with ["br" -> ".br"] and ["gzip" -> ".gz"].
extensions - the extensions to use.registerExtension(String, String)public Map<String,String> getExtensions()
public void registerExtension(String coding, String extension)
setExtensions(Map).coding - the content codingextension - the associated file extensionprotected Resource resolveResourceInternal(@Nullable HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain)
resolveResourceInternal in class AbstractResourceResolverprotected String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain)
resolveUrlPathInternal in class AbstractResourceResolver