Class CssLinkResourceTransformer
- java.lang.Object
- org.springframework.web.servlet.resource.ResourceTransformerSupport
- org.springframework.web.servlet.resource.CssLinkResourceTransformer
- All Implemented Interfaces:
ResourceTransformer
public class CssLinkResourceTransformer extends ResourceTransformerSupport
AResourceTransformer
implementation that modifies links in a CSS file to match the public URL paths that should be exposed to clients (e.g. with an MD5 content-based hash inserted in the URL).The implementation looks for links in CSS
@import
statements and also inside CSSurl()
functions. All links are then passed through theResourceResolverChain
and resolved relative to the location of the containing CSS file. If successfully resolved, the link is modified, otherwise the original link is preserved.- Since:
- 4.1
- Author:
- Rossen Stoyanchev
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
CssLinkResourceTransformer.AbstractCssLinkParser
protected static interface
CssLinkResourceTransformer.CssLinkParser
Constructor Summary
Constructors Constructor Description CssLinkResourceTransformer()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Resource
transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
Transform the given resource.Methods inherited from class org.springframework.web.servlet.resource.ResourceTransformerSupport
getResourceUrlProvider, resolveUrlPath, setResourceUrlProvider
Constructor Detail
CssLinkResourceTransformer
public CssLinkResourceTransformer()
Method Detail
transform
public Resource transform(HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain) throws IOException
Description copied from interface:ResourceTransformer
Transform the given resource.- Parameters:
request
- the current requestresource
- the resource to transformtransformerChain
- the chain of remaining transformers to delegate to- Returns:
- the transformed resource (never
null
) - Throws:
IOException
- if the transformation fails