Package org.springframework.web.servlet.resource

# 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
A `ResourceTransformer` implementation that modifies links in a CSS file to match the public URL paths that should be exposed to clients (for example, with an MD5 content-based hash inserted in the URL).

The implementation looks for links in CSS `@import` statements and also inside CSS `url()` functions. All links are then passed through the `ResourceResolverChain` 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.AbstractLinkParser`
Abstract base class for `CssLinkResourceTransformer.LinkParser` implementations.
`protected static interface`
`CssLinkResourceTransformer.LinkParser`
Extract content chunks that represent links.

## Constructor Summary

Constructors
Constructor
Description
`CssLinkResourceTransformer()`

## Method Summary

Modifier and Type
Method
Description
`org.springframework.core.io.Resource`
`transform(HttpServletRequest request, org.springframework.core.io.Resource resource, ResourceTransformerChain transformerChain)`
Transform the given resource.

### Methods inherited from class org.springframework.web.servlet.resource.ResourceTransformerSupport

`getResourceUrlProvider, resolveUrlPath, setResourceUrlProvider, toAbsolutePath`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CssLinkResourceTransformer

public CssLinkResourceTransformer()

## Method Details

### transform

public org.springframework.core.io.Resource transform(HttpServletRequest request, org.springframework.core.io.Resource resource, ResourceTransformerChain transformerChain) throws IOException
Description copied from interface: `ResourceTransformer`
Transform the given resource.

Parameters:
  `request` - the current request
  `resource` - the resource to transform
  `transformerChain` - the chain of remaining transformers to delegate to
Returns:
  the transformed resource (never `null`)
Throws:
  `IOException` - if the transformation fails