public class ContentBasedVersionStrategy extends AbstractVersionStrategy
VersionStrategy that handles version strings as a Hex MD5 hash in resource file names.
For example the path "styles/foo-e36d2e05253c6c7085a91522ce43a0b4.css" will match to "styles/foo.css" assuming the hash computed from the content of "foo.css" matches the hash in the path.
VersionResourceResolverlogger| Constructor and Description |
|---|
ContentBasedVersionStrategy() |
| Modifier and Type | Method and Description |
|---|---|
String |
addVersionToUrl(String baseUrl,
List<? extends org.springframework.core.io.Resource> locations,
ResourceResolverChain chain)
Adds a version string to the given baseUrl.
|
String |
deleteVersionFromPath(String requestPath,
String candidateVersion)
Deletes the given candidate version string from the given request path.
|
String |
extractVersionFromPath(String requestPath)
Extracts a version string from the request path.
|
boolean |
resourceVersionMatches(org.springframework.core.io.Resource baseResource,
String candidateVersion)
Checks whether the given
Resource matches the candidate version string. |
addVersionAsPrefix, addVersionToFilename, deleteVersionAsPrefix, deleteVersionFromFilename, extractVersionAsPrefix, extractVersionFromFilenamepublic String extractVersionFromPath(String requestPath)
VersionStrategyrequestPath - the request path of the resource being resolvedpublic String deleteVersionFromPath(String requestPath, String candidateVersion)
VersionStrategyrequestPath - the request path of the resource being resolvedcandidateVersion - the candidate version stringpublic boolean resourceVersionMatches(org.springframework.core.io.Resource baseResource,
String candidateVersion)
VersionStrategyResource matches the candidate version string.
Useful when the version string is managed on a per-resource basis.baseResource - the resource to check against the given versioncandidateVersion - the candidate version for the given resourcepublic String addVersionToUrl(String baseUrl, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
VersionStrategybaseUrl - the baseUrl of the requested resourcelocations - the resource locations to resolve resources fromchain - the chain of resource resolvers