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.
| Modifier and Type | Field and Description |
|---|---|
| private Resource[] | |
| private final Map | |
| private UrlPathHelper |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | Returns: "true" if resource is in a valid location, "false" otherwisethe resource to check resource, Resource the location relative to which the resource was found location)Perform additional checks on a resolved resource beyond checking whether the resource exists and is readable. |
| private String | |
| public Resource[] | |
| public Map | |
| private Resource | |
| protected Resource | Returns: the resource, ornull if none foundthe path to the resource resourcePath, Resource the location to check location)Find the resource under the given location. |
| public UrlPathHelper | |
| private boolean | |
| private boolean | |
| protected Resource | resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain)
Implements abstract org.
|
| protected String | resolveUrlPathInternal(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain)
Implements abstract org.
|
| public void | setAllowedLocations(Resource...
the list of allowed locations 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. |
| public void | setLocationCharsets(Map<Resource, Charset> locationCharsets)
Configure charsets associated with locations. |
| public void | setUrlPathHelper(UrlPathHelper urlPathHelper)
Provide a reference to the |
| private boolean | shouldDecodeRelativePath(Resource location, boolean usesPathPattern)
When the |
| private boolean | shouldEncodeRelativePath(Resource location, boolean usesPathPattern)
When the |
| allowedLocations | back to summary |
|---|---|
| private Resource[] allowedLocations
| |
| locationCharsets | back to summary |
|---|---|
| private final Map<Resource, Charset> locationCharsets | |
| urlPathHelper | back to summary |
|---|---|
| private UrlPathHelper urlPathHelper
| |
| PathResourceResolver | back to summary |
|---|---|
| public PathResourceResolver() | |
| checkResource | back to summary |
|---|---|
| protected boolean checkResource(Resource resource, Resource location) throws IOException Perform additional checks on a resolved resource beyond checking whether the resource exists and is readable. The default implementation also verifies the resource is either under the location relative to which it was found or is under one of the allowed locations. | |
| encodeOrDecodeIfNecessary | back to summary |
|---|---|
| private String encodeOrDecodeIfNecessary(String path, HttpServletRequest request, Resource location) | |
| getAllowedLocations | back to summary |
|---|---|
public Resource[] getAllowedLocations()
| |
| getLocationCharsets | back to summary |
|---|---|
| public Map Return charsets associated with static resource locations.
| |
| getResource | back to summary |
|---|---|
private Resource getResource(String resourcePath, HttpServletRequest request, List<? extends Resource> locations)
| |
| getResource | back to summary |
|---|---|
| protected Resource getResource(String resourcePath, Resource location) throws IOException Find the resource under the given location. The default implementation checks if there is a readable
| |
| getUrlPathHelper | back to summary |
|---|---|
| public UrlPathHelper getUrlPathHelper() The configured
| |
| isInvalidEncodedPath | back to summary |
|---|---|
| private boolean isInvalidEncodedPath(String resourcePath) | |
| isResourceUnderLocation | back to summary |
|---|---|
| private boolean isResourceUnderLocation(Resource resource, Resource location) throws IOException | |
| resolveResourceInternal | back to summary |
|---|---|
| protected Resource resolveResourceInternal(HttpServletRequest request, String requestPath, List<? extends Resource> locations, ResourceResolverChain chain) Implements abstract org. | |
| resolveUrlPathInternal | back to summary |
|---|---|
| protected String resolveUrlPathInternal(String resourcePath, List<? extends Resource> locations, ResourceResolverChain chain) Implements abstract org. | |
| setAllowedLocations | back to summary |
|---|---|
| public void setAllowedLocations(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.
However sometimes that may not be the case, e.g. when
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
| |
| setLocationCharsets | back to summary |
|---|---|
| public void setLocationCharsets(Map<Resource, Charset> locationCharsets) Configure charsets associated with locations. If a static resource is found
under a Note the charset is used only if the
| |
| setUrlPathHelper | back to summary |
|---|---|
| public void setUrlPathHelper(UrlPathHelper urlPathHelper) Provide a reference to the
| |
| shouldDecodeRelativePath | back to summary |
|---|---|
| private boolean shouldDecodeRelativePath(Resource location, boolean usesPathPattern) When the | |
| shouldEncodeRelativePath | back to summary |
|---|---|
| private boolean shouldEncodeRelativePath(Resource location, boolean usesPathPattern) When the | |