类 ResourceTransformerSupport
- java.lang.Object
- org.springframework.web.servlet.resource.ResourceTransformerSupport
- 所有已实现的接口:
ResourceTransformer
public abstract class ResourceTransformerSupport extends Object implements ResourceTransformer
A base class for aResourceTransformer
with an optional helper method for resolving public links within a transformed resource.- 从以下版本开始:
- 4.1
- 作者:
- Brian Clozel, Rossen Stoyanchev
构造器概要
构造器 构造器 说明 ResourceTransformerSupport()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResourceUrlProvider
getResourceUrlProvider()
Return the configuredResourceUrlProvider
.protected String
resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
A transformer can use this method when a resource being transformed contains links to other resources.void
setResourceUrlProvider(ResourceUrlProvider resourceUrlProvider)
Configure aResourceUrlProvider
to use when resolving the public URL of links in a transformed resource (e.g. import links in a CSS file).从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.servlet.resource.ResourceTransformer
transform
构造器详细资料
ResourceTransformerSupport
public ResourceTransformerSupport()
方法详细资料
setResourceUrlProvider
public void setResourceUrlProvider(ResourceUrlProvider resourceUrlProvider)
Configure aResourceUrlProvider
to use when resolving the public URL of links in a transformed resource (e.g. import links in a CSS file). This is required only for links expressed as full paths, i.e. including context and servlet path, and not for relative links.By default this property is not set. In that case if a
ResourceUrlProvider
is needed an attempt is made to find theResourceUrlProvider
exposed through theResourceUrlProviderExposingInterceptor
(configured by default in the MVC Java config and XML namespace). Therefore explicitly configuring this property should not be needed in most cases.- 参数:
resourceUrlProvider
- the URL provider to use
getResourceUrlProvider
public ResourceUrlProvider getResourceUrlProvider()
Return the configuredResourceUrlProvider
.
resolveUrlPath
protected String resolveUrlPath(String resourcePath, HttpServletRequest request, Resource resource, ResourceTransformerChain transformerChain)
A transformer can use this method when a resource being transformed contains links to other resources. Such links need to be replaced with the public facing link as determined by the resource resolver chain (e.g. the public URL may have a version inserted).- 参数:
resourcePath
- the path to a resource that needs to be re-writtenrequest
- the current requestresource
- the resource being transformedtransformerChain
- the transformer chain- 返回:
- the resolved URL, or if not resolvable