public class VersionResourceResolver extends AbstractResourceResolver
ResourceResolver that resolves request paths containing a version
string, i.e. version information about the resource being requested.
This resolver can be useful to set up HTTP caching strategies by changing
resources' URLs as they are updated.
Because resource versioning depends on the resource types, this ResourceResolver
needs to be configured with at least one VersionStrategy. The process of matching
and generating version strings is delegated to the VersionStrategy.
When resolving resources, this resolver will first delegate to the chain to locate an existing resource and then attempt to extract a version string from the request path and then find a resource that matches that version.
When resolving URLs, this resolver will, if necessary, add a version string in the request path.
VersionStrategylogger| Constructor and Description |
|---|
VersionResourceResolver() |
| Modifier and Type | Method and Description |
|---|---|
protected VersionStrategy |
getStrategyForPath(String requestPath)
Finds a
VersionStrategy for the request path of the requested resource. |
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 |
setStrategyMap(Map<String,VersionStrategy> versionStrategyMap)
Set a Map with URL paths as keys and
VersionStrategy
as values. |
resolveResource, resolveUrlPathpublic void setStrategyMap(Map<String,VersionStrategy> versionStrategyMap)
VersionStrategy
as values.
Supports direct URL matches and Ant-style pattern matches. For syntax
details, see the AntPathMatcher javadoc.
versionStrategyMap - map with URLs as keys and version strategies as valuesprotected Resource resolveResourceInternal(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 AbstractResourceResolverprotected VersionStrategy getStrategyForPath(String requestPath)
VersionStrategy for the request path of the requested resource.VersionStrategy or null if none matches that request path