类 ResourceTransformerSupport
- java.lang.Object
- org.springframework.web.reactive.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.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Brian Clozel
构造器概要
构造器 构造器 说明 ResourceTransformerSupport()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 ResourceUrlProvider
getResourceUrlProvider()
Return the configuredResourceUrlProvider
.protected reactor.core.publisher.Mono<String>
resolveUrlPath(String resourcePath, ServerWebExchange exchange, 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).protected String
toAbsolutePath(String path, ServerWebExchange exchange)
Transform the given relative request path to an absolute path, taking the path of the given request as a point of reference.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.reactive.resource.ResourceTransformer
transform
构造器详细资料
ResourceTransformerSupport
public ResourceTransformerSupport()
方法详细资料
setResourceUrlProvider
public void setResourceUrlProvider(@Nullable 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 and not for relative links.- 参数:
resourceUrlProvider
- the URL provider to use
getResourceUrlProvider
@Nullable public ResourceUrlProvider getResourceUrlProvider()
Return the configuredResourceUrlProvider
.
resolveUrlPath
protected reactor.core.publisher.Mono<String> resolveUrlPath(String resourcePath, ServerWebExchange exchange, 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-writtenexchange
- the current exchangeresource
- the resource being transformedtransformerChain
- the transformer chain- 返回:
- the resolved URL or an empty
Mono
toAbsolutePath
protected String toAbsolutePath(String path, ServerWebExchange exchange)
Transform the given relative request path to an absolute path, taking the path of the given request as a point of reference. The resulting path is also cleaned from sequences like "path/..".- 参数:
path
- the relative path to transformexchange
- the current exchange- 返回:
- the absolute request path for the given resource path