org.springframework.web.servlet.resource

Class AbstractVersionStrategy

  • java.lang.Object
    • org.springframework.web.servlet.resource.AbstractVersionStrategy
  • All Implemented Interfaces:
    VersionPathStrategy, VersionStrategy
    Direct Known Subclasses:
    ContentVersionStrategy, FixedVersionStrategy


    public abstract class AbstractVersionStrategy
    extends java.lang.Object
    implements VersionStrategy
    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
    • Field Detail

      • logger

        protected final Log logger
    • Constructor Detail

      • AbstractVersionStrategy

        protected AbstractVersionStrategy(VersionPathStrategy pathStrategy)
    • Method Detail

      • extractVersion

        @Nullable
        public java.lang.String extractVersion(java.lang.String requestPath)
        Description copied from interface: VersionPathStrategy
        Extract the resource version from the request path.
        Specified by:
        extractVersion in interface VersionPathStrategy
        Parameters:
        requestPath - the request path to check
        Returns:
        the version string or null if none was found
      • addVersion

        public java.lang.String addVersion(java.lang.String requestPath,
                                           java.lang.String version)
        Description copied from interface: VersionPathStrategy
        Add a version to the given request path.
        Specified by:
        addVersion in interface VersionPathStrategy
        Parameters:
        requestPath - the requestPath
        version - the version
        Returns:
        the requestPath updated with a version string