org.springframework.web.context.support

Class ServletContextResource

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Resource createRelative(java.lang.String relativePath)
      This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor.
      boolean equals(java.lang.Object other)
      This implementation compares the underlying ServletContext resource locations.
      boolean exists()
      This implementation checks ServletContext.getResource.
      java.lang.String getDescription()
      This implementation returns a description that includes the ServletContext resource location.
      java.io.File getFile()
      This implementation resolves "file:" URLs or alternatively delegates to ServletContext.getRealPath, throwing a FileNotFoundException if not found or not resolvable.
      java.lang.String getFilename()
      This implementation returns the name of the file that this ServletContext resource refers to.
      java.io.InputStream getInputStream()
      This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if no resource found.
      java.lang.String getPath()
      Return the path for this resource.
      java.lang.String getPathWithinContext()
      Return the path within the enclosing 'context'.
      ServletContext getServletContext()
      Return the ServletContext for this resource.
      java.net.URL getURL()
      This implementation delegates to ServletContext.getResource, but throws a FileNotFoundException if no resource found.
      int hashCode()
      This implementation returns the hash code of the underlying ServletContext resource location.
      boolean isFile()
      This implementation always returns false.
      boolean isReadable()
      This implementation delegates to ServletContext.getResourceAsStream, which returns null in case of a non-readable resource (e.g.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ServletContextResource

        public ServletContextResource(ServletContext servletContext,
                                      java.lang.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