public class ServletContextResourcePatternResolver extends PathMatchingResourcePatternResolver
PathMatchingResourcePatternResolver
,
able to find matching resources below the web application root directory
via Servlet 2.3's ServletContext.getResourcePaths
.
Falls back to the superclass' file system checking for other resources.CLASSPATH_ALL_URL_PREFIX
CLASSPATH_URL_PREFIX
Constructor and Description |
---|
ServletContextResourcePatternResolver(ResourceLoader resourceLoader)
Create a new ServletContextResourcePatternResolver.
|
ServletContextResourcePatternResolver(ServletContext servletContext)
Create a new ServletContextResourcePatternResolver.
|
Modifier and Type | Method and Description |
---|---|
protected Set<Resource> |
doFindPathMatchingFileResources(Resource rootDirResource,
String subPattern)
Overridden version which checks for ServletContextResource
and uses
ServletContext.getResourcePaths to find
matching resources below the web application root directory. |
protected void |
doRetrieveMatchingServletContextResources(ServletContext servletContext,
String fullPattern,
String dir,
Set<Resource> result)
Recursively retrieve ServletContextResources that match the given pattern,
adding them to the given result set.
|
convertClassLoaderURL, determineRootDir, doFindMatchingFileSystemResources, doFindPathMatchingJarResources, doRetrieveMatchingFiles, findAllClassPathResources, findPathMatchingResources, getClassLoader, getJarFile, getPathMatcher, getResource, getResourceLoader, getResources, isJarResource, resolveRootDirResource, retrieveMatchingFiles, setPathMatcher
public ServletContextResourcePatternResolver(ServletContext servletContext)
servletContext
- the ServletContext to load resources withServletContextResourceLoader.ServletContextResourceLoader(javax.servlet.ServletContext)
public ServletContextResourcePatternResolver(ResourceLoader resourceLoader)
resourceLoader
- the ResourceLoader to load root directories and
actual resources withprotected Set<Resource> doFindPathMatchingFileResources(Resource rootDirResource, String subPattern) throws IOException
ServletContext.getResourcePaths
to find
matching resources below the web application root directory.
In case of other resources, delegates to the superclass version.doFindPathMatchingFileResources
in class PathMatchingResourcePatternResolver
rootDirResource
- the root directory as ResourcesubPattern
- the sub pattern to match (below the root directory)IOException
- in case of I/O errorsdoRetrieveMatchingServletContextResources(javax.servlet.ServletContext, java.lang.String, java.lang.String, java.util.Set<org.springframework.core.io.Resource>)
,
ServletContextResource
,
ServletContext.getResourcePaths(java.lang.String)
protected void doRetrieveMatchingServletContextResources(ServletContext servletContext, String fullPattern, String dir, Set<Resource> result) throws IOException
servletContext
- the ServletContext to work onfullPattern
- the pattern to match against,
with preprended root directory pathdir
- the current directoryresult
- the Set of matching Resources to add toIOException
- if directory contents could not be retrievedServletContextResource
,
ServletContext.getResourcePaths(java.lang.String)