Class AbstractVersionStrategy
java.lang.Object
org.springframework.web.servlet.resource.AbstractVersionStrategy
- All Implemented Interfaces:
VersionPathStrategy
,VersionStrategy
- Direct Known Subclasses:
ContentVersionStrategy
,FixedVersionStrategy
Abstract base class for
VersionStrategy
implementations.
Supports versions as:
- prefix in the request path, like "version/static/myresource.js"
- file name suffix in the request path, like "static/myresource-version.js"
Note: This base class does not provide support for generating the version string.
- Since:
- 4.1
- Author:
- Brian Clozel, Rossen Stoyanchev
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
File name-basedVersionPathStrategy
, for example,"path/foo-{version}.css"
.protected static class
A prefix-basedVersionPathStrategy
, for example,"{version}/path/foo.js"
. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractVersionStrategy
(VersionPathStrategy pathStrategy) -
Method Summary
Modifier and TypeMethodDescriptionaddVersion
(String requestPath, String version) Add a version to the given request path.extractVersion
(String requestPath) Extract the resource version from the request path.removeVersion
(String requestPath, String version) Remove the version from the request path.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.servlet.resource.VersionStrategy
getResourceVersion
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AbstractVersionStrategy
-
-
Method Details
-
getVersionPathStrategy
-
extractVersion
Description copied from interface:VersionPathStrategy
Extract the resource version from the request path.- Specified by:
extractVersion
in interfaceVersionPathStrategy
- Parameters:
requestPath
- the request path to check- Returns:
- the version string or
null
if none was found
-
removeVersion
Description copied from interface:VersionPathStrategy
Remove the version from the request path. It is assumed that the given version was extracted viaVersionPathStrategy.extractVersion(String)
.- Specified by:
removeVersion
in interfaceVersionPathStrategy
- Parameters:
requestPath
- the request path of the resource being resolvedversion
- the version obtained fromVersionPathStrategy.extractVersion(String)
- Returns:
- the request path with the version removed
-
addVersion
Description copied from interface:VersionPathStrategy
Add a version to the given request path.- Specified by:
addVersion
in interfaceVersionPathStrategy
- Parameters:
requestPath
- the requestPathversion
- the version- Returns:
- the requestPath updated with a version string
-