Home » Spring-Framework-090522 » org.springframework » web » context » support » [javadoc | source]
org.springframework.web.context.support
public class: ServletContextResource [javadoc | source]
java.lang.Object
   org.springframework.core.io.AbstractResource
      org.springframework.web.context.support.ServletContextResource

All Implemented Interfaces:
    ContextResource, Resource

org.springframework.core.io.Resource implementation for javax.servlet.ServletContext resources, interpreting relative paths within the web application root directory.

Always supports stream access and URL access, but only allows java.io.File access when the web application archive is expanded.

Constructor:
 public ServletContextResource(ServletContext servletContext,
    String path) 
    Create a new ServletContextResource.

    The Servlet spec requires that resource paths start with a slash, even if many containers accept paths without leading slash too. Consequently, the given path will be prepended with a slash if it doesn't already start with one.

    Parameters:
    servletContext - the ServletContext to load from
    path - the path of the resource
Method from org.springframework.web.context.support.ServletContextResource Summary:
createRelative,   equals,   exists,   getDescription,   getFile,   getFilename,   getInputStream,   getPath,   getPathWithinContext,   getServletContext,   getURL,   hashCode
Methods from org.springframework.core.io.AbstractResource:
createRelative,   equals,   exists,   getFile,   getFileForLastModifiedCheck,   getFilename,   getURI,   getURL,   hashCode,   isOpen,   isReadable,   lastModified,   toString
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.context.support.ServletContextResource Detail:
 public Resource createRelative(String relativePath) 
    This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor.
 public boolean equals(Object obj) 
    This implementation compares the underlying ServletContext resource locations.
 public boolean exists() 
    This implementation checks ServletContext.getResource.
 public String getDescription() 
    This implementation returns a description that includes the ServletContext resource location.
 public File getFile() throws IOException 
    This implementation delegates to ServletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable.
 public String getFilename() 
    This implementation returns the name of the file that this ServletContext resource refers to.
 public InputStream getInputStream() throws IOException 
    This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if no resource found.
 public final String getPath() 
    Return the path for this resource.
 public String getPathWithinContext() 
 public final ServletContext getServletContext() 
    Return the ServletContext for this resource.
 public URL getURL() throws IOException 
    This implementation delegates to ServletContext.getResource, but throws a FileNotFoundException if no resource found.
 public int hashCode() 
    This implementation returns the hash code of the underlying ServletContext resource location.