Class LitewebJarsResourceResolver
java.lang.Object
org.springframework.web.servlet.resource.AbstractResourceResolver
org.springframework.web.servlet.resource.LitewebJarsResourceResolver
- All Implemented Interfaces:
ResourceResolver
A
ResourceResolver that delegates to the chain to locate a resource and then
attempts to find a matching versioned resource contained in a webJar JAR file.
This allows webJars.org users to write version agnostic paths in their templates,
like <script src="/webjars/jquery/jquery.min.js"/>.
This path will be resolved to the unique version <script src="/webjars/jquery/1.2.0/jquery.min.js"/>,
which is a better fit for HTTP caching and version management in applications.
This also resolves resources for version agnostic HTTP requests "GET /jquery/jquery.min.js".
This resolver requires the org.webjars:webjars-locator-lite library
on the classpath and is automatically registered if that library is present.
- Since:
- 6.2
- Author:
- Sebastien Deleuze
- See Also:
-
Field Summary
Fields inherited from class AbstractResourceResolver
logger -
Constructor Summary
ConstructorsConstructorDescriptionCreate aLitewebJarsResourceResolverwith a defaultwebJarVersionLocatorinstance.LitewebJarsResourceResolver(org.webjars.webJarVersionLocator webJarVersionLocator) Create aLitewebJarsResourceResolverwith a customwebJarVersionLocatorinstance, for example, with a custom cache implementation. -
Method Summary
Modifier and TypeMethodDescriptionfindwebJarResourcePath(String path) resolveResourceInternal(@Nullable jakarta.servlet.http.HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) Methods inherited from class AbstractResourceResolver
resolveResource, resolveUrlPath
-
Constructor Details
-
LitewebJarsResourceResolver
public LitewebJarsResourceResolver()Create aLitewebJarsResourceResolverwith a defaultwebJarVersionLocatorinstance. -
LitewebJarsResourceResolver
public LitewebJarsResourceResolver(org.webjars.webJarVersionLocator webJarVersionLocator) Create aLitewebJarsResourceResolverwith a customwebJarVersionLocatorinstance, for example, with a custom cache implementation.
-
-
Method Details
-
resolveResourceInternal
protected @Nullable Resource resolveResourceInternal(@Nullable jakarta.servlet.http.HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) - Specified by:
resolveResourceInternalin classAbstractResourceResolver
-
resolveUrlPathInternal
protected @Nullable String resolveUrlPathInternal(String resourceUrlPath, List<? extends Resource> locations, ResourceResolverChain chain) - Specified by:
resolveUrlPathInternalin classAbstractResourceResolver
-
findwebJarResourcePath
-