public class PathResourceResolver extends AbstractResourceResolver
ResourceResolver that tries to find a resource under the given
locations matching to the request path.
This resolver does not delegate to the ResourceResolverChain and is
expected to be configured at the end in a chain of resolvers.
logger| Constructor and Description |
|---|
PathResourceResolver() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkResource(org.springframework.core.io.Resource resource,
org.springframework.core.io.Resource location)
Perform additional checks on a resolved resource beyond checking whether the
resources exists and is readable.
|
org.springframework.core.io.Resource[] |
getAllowedLocations() |
protected reactor.core.publisher.Mono<org.springframework.core.io.Resource> |
getResource(String resourcePath,
org.springframework.core.io.Resource location)
Find the resource under the given location.
|
protected reactor.core.publisher.Mono<org.springframework.core.io.Resource> |
resolveResourceInternal(org.springframework.web.server.ServerWebExchange exchange,
String requestPath,
List<? extends org.springframework.core.io.Resource> locations,
ResourceResolverChain chain) |
protected reactor.core.publisher.Mono<String> |
resolveUrlPathInternal(String path,
List<? extends org.springframework.core.io.Resource> locations,
ResourceResolverChain chain) |
void |
setAllowedLocations(org.springframework.core.io.Resource... locations)
By default when a Resource is found, the path of the resolved resource is
compared to ensure it's under the input location where it was found.
|
resolveResource, resolveUrlPathpublic void setAllowedLocations(@Nullable
org.springframework.core.io.Resource... locations)
CssLinkResourceTransformer
resolves public URLs of links it contains, the CSS file is the location
and the resources being resolved are css files, images, fonts and others
located in adjacent or parent directories.
This property allows configuring a complete list of locations under which resources must be so that if a resource is not under the location relative to which it was found, this list may be checked as well.
By default ResourceWebHandler initializes this property
to match its list of locations.
locations - the list of allowed locations@Nullable public org.springframework.core.io.Resource[] getAllowedLocations()
protected reactor.core.publisher.Mono<org.springframework.core.io.Resource> resolveResourceInternal(@Nullable
org.springframework.web.server.ServerWebExchange exchange,
String requestPath,
List<? extends org.springframework.core.io.Resource> locations,
ResourceResolverChain chain)
resolveResourceInternal in class AbstractResourceResolverprotected reactor.core.publisher.Mono<String> resolveUrlPathInternal(String path, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
resolveUrlPathInternal in class AbstractResourceResolverprotected reactor.core.publisher.Mono<org.springframework.core.io.Resource> getResource(String resourcePath, org.springframework.core.io.Resource location)
The default implementation checks if there is a readable
Resource for the given path relative to the location.
resourcePath - the path to the resourcelocation - the location to checkMono if none foundprotected boolean checkResource(org.springframework.core.io.Resource resource,
org.springframework.core.io.Resource location)
throws IOException
allowed locations.resource - the resource to checklocation - the location relative to which the resource was foundIOException