Top Description Methods
org.springframework.web.servlet.resource

public Interface ResourceResolver

Known Direct Implementers
org.springframework.web.servlet.resource.AbstractResourceResolver
Imports
java.util.List, jakarta.servlet.http.HttpServletRequest, org.springframework.core.io.Resource, org.springframework.lang.Nullable

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

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

Authors
Jeremy Grelle, Rossen Stoyanchev, Sam Brannen
Since
4.1
See Also
org.springframework.web.servlet.resource.ResourceResolverChain

Method Summary

Modifier and TypeMethod and Description
public Resource

Returns:

the resolved resource, or null if unresolved
resolveResource
(HttpServletRequest
the current request (may not be present in some calls)
request
,
String
the portion of the request path to use
requestPath
,
List<? extends Resource>
the locations to search in when looking up resources
locations
,
ResourceResolverChain
the chain of remaining resolvers to delegate to
chain
)

Resolve the supplied request and request path to a Resource that exists under one of the given resource locations.

public String

Returns:

the resolved public URL path, or null if unresolved
resolveUrlPath
(String
the internal resource path
resourcePath
,
List<? extends Resource>
the locations to search in when looking up resources
locations
,
ResourceResolverChain
the chain of resolvers to delegate to
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 Detail

resolveResourceback to summary
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain)

Resolve the supplied request and request path to a Resource that exists under one of the given resource locations.

Parameters
request:HttpServletRequest

the current request (may not be present in some calls)

requestPath:String

the portion of the request path to use

locations:List<? extends Resource>

the locations to search in when looking up resources

chain:ResourceResolverChain

the chain of remaining resolvers to delegate to

Returns:Resource

the resolved resource, or null if unresolved

Annotations
@Nullable
resolveUrlPathback to summary
public String resolveUrlPath(String resourcePath, List<? extends 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:String

the internal resource path

locations:List<? extends Resource>

the locations to search in when looking up resources

chain:ResourceResolverChain

the chain of resolvers to delegate to

Returns:String

the resolved public URL path, or null if unresolved

Annotations
@Nullable