org.springframework.web.context.support
Class ServletContextResourcePatternResolver
java.lang.Object
org.springframework.core.io.support.PathMatchingResourcePatternResolver
org.springframework.web.context.support.ServletContextResourcePatternResolver
- All Implemented Interfaces:
- ResourceLoader, ResourcePatternResolver
- public class ServletContextResourcePatternResolver
- extends PathMatchingResourcePatternResolver
ServletContext-aware subclass of 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.
The advantage of using ServletContext.getResourcePaths
to
find matching files is that it will work in a WAR file which has not been
expanded too. For Servlet containers that do not support Servlet 2.3 or
above, this resolver will always fall back to file system checking,
which requires an expanded WAR file.
- Since:
- 1.1.2
- Author:
- Juergen Hoeller
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ServletContextResourcePatternResolver
public ServletContextResourcePatternResolver(ResourceLoader resourceLoader)
- Create a new ServletContextResourcePatternResolver.
ClassLoader access will happen via the thread context class loader on actual
access (applying to the thread that does the "getResources" call)
- Parameters:
resourceLoader
- the ResourceLoader to load root directories and
actual resources with
doFindPathMatchingFileResources
protected List doFindPathMatchingFileResources(Resource rootDirResource,
String subPattern)
throws IOException
- Overridden version which checks for ServletContextResource
and uses
ServletContext.getResourcePaths
to find
matching resources below the web application root directory.
In case of other resources, delegates to the superclass version.
- Overrides:
doFindPathMatchingFileResources
in class PathMatchingResourcePatternResolver
- Parameters:
rootDirResource
- the root directory as ResourcesubPattern
- the sub pattern to match (below the root directory)
- Returns:
- the List of matching Resource instances
- Throws:
IOException
- in case of I/O errors- See Also:
doRetrieveMatchingServletContextResources(javax.servlet.ServletContext, java.lang.String, java.lang.String, java.util.List)
,
ServletContextResource
,
ServletContext.getResourcePaths(java.lang.String)
doRetrieveMatchingServletContextResources
protected void doRetrieveMatchingServletContextResources(ServletContext servletContext,
String fullPattern,
String dir,
List result)
throws IOException
- Recursively retrieve ServletContextResources that match the given pattern,
adding them to the given result list.
- Parameters:
servletContext
- the ServletContext to work onfullPattern
- the pattern to match against,
with preprended root directory pathdir
- the current directoryresult
- the list of matching files to add to
- Throws:
IOException
- if directory contents could not be retrieved- See Also:
ServletContextResource
,
ServletContext.getResourcePaths(java.lang.String)
Copyright (C) 2003-2004 The Spring Framework Project.