类 ServletContextResource

  • 所有已实现的接口:
    org.springframework.core.io.ContextResource, org.springframework.core.io.InputStreamSource, org.springframework.core.io.Resource

    public class ServletContextResource
    extends org.springframework.core.io.AbstractFileResolvingResource
    implements org.springframework.core.io.ContextResource
    版本:
    $Id: ServletContextResource.java Dec 21, 2011 4:53:53 PM chaostone $
    作者:
    chaostone
    • 构造器概要

      构造器 
      构造器 说明
      ServletContextResource​(jakarta.servlet.ServletContext servletContext, String path)
      Create a new ServletContextResource.
    • 方法概要

      所有方法 实例方法 具体方法 
      修饰符和类型 方法 说明
      org.springframework.core.io.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.
      boolean equals​(Object obj)
      This implementation compares the underlying ServletContext resource locations.
      boolean exists()
      This implementation checks ServletContext.getResource.
      String getDescription()
      This implementation returns a description that includes the ServletContext resource location.
      File getFile()
      but throws a FileNotFoundException if not found or not resolvable.
      String getFilename()
      This implementation returns the name of the file that this ServletContext resource refers to.
      InputStream getInputStream()
      This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if no resource found.
      String getPath()
      Return the path for this resource.
      String getPathWithinContext()  
      jakarta.servlet.ServletContext getServletContext()
      Return the ServletContext for this resource.
      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.
      • 从类继承的方法 org.springframework.core.io.AbstractFileResolvingResource

        contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, isReadable, lastModified
      • 从类继承的方法 org.springframework.core.io.AbstractResource

        getURI, isOpen, toString
      • 从接口继承的方法 org.springframework.core.io.Resource

        contentLength, getURI, isOpen, isReadable, lastModified
    • 构造器详细资料

      • ServletContextResource

        public ServletContextResource​(jakarta.servlet.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.

        参数:
        servletContext - the ServletContext to load from
        path - the path of the resource
    • 方法详细资料

      • getServletContext

        public final jakarta.servlet.ServletContext getServletContext()
        Return the ServletContext for this resource.
      • getPath

        public final String getPath()
        Return the path for this resource.
      • exists

        public boolean exists()
        This implementation checks ServletContext.getResource.
        指定者:
        exists 在接口中 org.springframework.core.io.Resource
        覆盖:
        exists 在类中 org.springframework.core.io.AbstractFileResolvingResource
        另请参阅:
        ServletContext.getResource(String)
      • getInputStream

        public InputStream getInputStream()
                                   throws IOException
        This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if no resource found.
        指定者:
        getInputStream 在接口中 org.springframework.core.io.InputStreamSource
        抛出:
        IOException
        另请参阅:
        ServletContext.getResourceAsStream(String)
      • getURL

        public URL getURL()
                   throws IOException
        This implementation delegates to ServletContext.getResource, but throws a FileNotFoundException if no resource found.
        指定者:
        getURL 在接口中 org.springframework.core.io.Resource
        覆盖:
        getURL 在类中 org.springframework.core.io.AbstractResource
        抛出:
        IOException
        另请参阅:
        ServletContext.getResource(String)
      • getFile

        public File getFile()
                     throws IOException
        but throws a FileNotFoundException if not found or not resolvable.
        指定者:
        getFile 在接口中 org.springframework.core.io.Resource
        覆盖:
        getFile 在类中 org.springframework.core.io.AbstractFileResolvingResource
        抛出:
        IOException
      • createRelative

        public org.springframework.core.io.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.
        指定者:
        createRelative 在接口中 org.springframework.core.io.Resource
        覆盖:
        createRelative 在类中 org.springframework.core.io.AbstractResource
      • getFilename

        public String getFilename()
        This implementation returns the name of the file that this ServletContext resource refers to.
        指定者:
        getFilename 在接口中 org.springframework.core.io.Resource
        覆盖:
        getFilename 在类中 org.springframework.core.io.AbstractResource
      • getDescription

        public String getDescription()
        This implementation returns a description that includes the ServletContext resource location.
        指定者:
        getDescription 在接口中 org.springframework.core.io.Resource
      • getPathWithinContext

        public String getPathWithinContext()
        指定者:
        getPathWithinContext 在接口中 org.springframework.core.io.ContextResource
      • equals

        public boolean equals​(Object obj)
        This implementation compares the underlying ServletContext resource locations.
        覆盖:
        equals 在类中 org.springframework.core.io.AbstractResource
      • hashCode

        public int hashCode()
        This implementation returns the hash code of the underlying ServletContext resource location.
        覆盖:
        hashCode 在类中 org.springframework.core.io.AbstractResource