Interface ResourceResolver

All Known Implementing Classes:
AbstractResourceResolver, CachingResourceResolver, EncodedResourceResolver, PathResourceResolver, VersionResourceResolver, WebJarsResourceResolver

public interface ResourceResolver
A strategy for resolving a request to a server-side resource.

Provides mechanisms for resolving an incoming request to an actual Resource and for obtaining the public URL path that clients should use when requesting the resource.

Since:
5.0
Author:
Rossen Stoyanchev
  • Method Summary

    Modifier and Type
    Method
    Description
    reactor.core.publisher.Mono<org.springframework.core.io.Resource>
    resolveResource(org.springframework.web.server.ServerWebExchange exchange, String requestPath, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
    Resolve the supplied request and request path to a Resource that exists under one of the given resource locations.
    reactor.core.publisher.Mono<String>
    resolveUrlPath(String resourcePath, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
    Resolve the externally facing public URL path for clients to use to access the resource that is located at the given internal resource path.
  • Method Details

    • resolveResource

      reactor.core.publisher.Mono<org.springframework.core.io.Resource> resolveResource(@Nullable org.springframework.web.server.ServerWebExchange exchange, String requestPath, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
      Resolve the supplied request and request path to a Resource that exists under one of the given resource locations.
      Parameters:
      exchange - the current exchange
      requestPath - the portion of the request path to use. This is expected to be the encoded path, i.e. PathContainer.value().
      locations - the locations to search in when looking up resources
      chain - the chain of remaining resolvers to delegate to
      Returns:
      the resolved resource or an empty Mono if unresolved
    • resolveUrlPath

      reactor.core.publisher.Mono<String> resolveUrlPath(String resourcePath, List<? extends org.springframework.core.io.Resource> locations, ResourceResolverChain chain)
      Resolve the externally facing public URL path for clients to use to access the resource that is located at the given internal resource path.

      This is useful when rendering URL links to clients.

      Parameters:
      resourcePath - the "internal" resource path to resolve a path for public use. This is expected to be the encoded path.
      locations - the locations to search in when looking up resources
      chain - the chain of resolvers to delegate to
      Returns:
      the resolved public URL path or an empty Mono if unresolved