类 ServletContextResource
java.lang.Object
cn.taketoday.core.io.AbstractResource
cn.taketoday.core.io.AbstractFileResolvingResource
cn.taketoday.web.servlet.support.ServletContextResource
- 所有已实现的接口:
cn.taketoday.core.io.ContextResource,cn.taketoday.core.io.InputStreamSource,cn.taketoday.core.io.Resource
public class ServletContextResource
extends cn.taketoday.core.io.AbstractFileResolvingResource
implements cn.taketoday.core.io.ContextResource
Resource implementation for
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.
- 从以下版本开始:
- 4.0 2022/2/20 16:27
- 作者:
- Juergen Hoeller, Harry Yang
- 另请参阅:
-
字段概要
字段从接口继承的字段 cn.taketoday.core.io.Resource
EMPTY_ARRAY -
构造器概要
构造器构造器说明ServletContextResource(ServletContext servletContext, String path) Create a new ServletContextResource. -
方法概要
修饰符和类型方法说明cn.taketoday.core.io.ResourcecreateRelative(String relativePath) This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor.booleanThis implementation compares the underlying ServletContext resource locations.booleanexists()This implementation checksServletContext.getResource.getFile()This implementation resolves "file:" URLs or alternatively delegates toServletContext.getRealPath, throwing a FileNotFoundException if not found or not resolvable.This implementation delegates toServletContext.getResourceAsStream, but throws a FileNotFoundException if no resource found.getName()This implementation returns the name of the file that this ServletContext resource refers to.final StringgetPath()Return the path for this resource.final ServletContextReturn the ServletContext for this resource.getURL()This implementation delegates toServletContext.getResource, but throws a FileNotFoundException if no resource found.inthashCode()This implementation returns the hash code of the underlying ServletContext resource location.booleanisFile()booleanThis implementation delegates toServletContext.getResourceAsStream, which returnsnullin case of a non-readable resource (e.g. a directory).toString()This implementation returns a description that includes the ServletContext resource location.从类继承的方法 cn.taketoday.core.io.AbstractFileResolvingResource
contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, isFile, lastModified, readableChannel从类继承的方法 cn.taketoday.core.io.AbstractResource
getURI, isDirectory, isOpen, list, list从接口继承的方法 cn.taketoday.core.io.InputStreamSource
getReader, getReader, readableChannel从接口继承的方法 cn.taketoday.core.io.Resource
contentLength, getContentAsByteArray, getContentAsString, getURI, isDirectory, isOpen, lastModified, list, list
-
字段详细资料
-
servletContext
-
path
-
-
构造器详细资料
-
ServletContextResource
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 frompath- the path of the resource
-
-
方法详细资料
-
getServletContext
Return the ServletContext for this resource. -
getPath
Return the path for this resource. -
exists
public boolean exists()This implementation checksServletContext.getResource.- 指定者:
exists在接口中cn.taketoday.core.io.Resource- 覆盖:
exists在类中cn.taketoday.core.io.AbstractFileResolvingResource- 另请参阅:
-
isReadable
public boolean isReadable()This implementation delegates toServletContext.getResourceAsStream, which returnsnullin case of a non-readable resource (e.g. a directory).- 指定者:
isReadable在接口中cn.taketoday.core.io.Resource- 覆盖:
isReadable在类中cn.taketoday.core.io.AbstractFileResolvingResource- 另请参阅:
-
isFile
public boolean isFile()- 指定者:
isFile在接口中cn.taketoday.core.io.Resource- 覆盖:
isFile在类中cn.taketoday.core.io.AbstractFileResolvingResource
-
getInputStream
This implementation delegates toServletContext.getResourceAsStream, but throws a FileNotFoundException if no resource found.- 指定者:
getInputStream在接口中cn.taketoday.core.io.InputStreamSource- 抛出:
IOException- 另请参阅:
-
getURL
This implementation delegates toServletContext.getResource, but throws a FileNotFoundException if no resource found.- 指定者:
getURL在接口中cn.taketoday.core.io.Resource- 覆盖:
getURL在类中cn.taketoday.core.io.AbstractResource- 抛出:
IOException- 另请参阅:
-
getFile
This implementation resolves "file:" URLs or alternatively delegates toServletContext.getRealPath, throwing a FileNotFoundException if not found or not resolvable.- 指定者:
getFile在接口中cn.taketoday.core.io.Resource- 覆盖:
getFile在类中cn.taketoday.core.io.AbstractFileResolvingResource- 抛出:
IOException- 另请参阅:
-
createRelative
This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor.- 指定者:
createRelative在接口中cn.taketoday.core.io.Resource- 覆盖:
createRelative在类中cn.taketoday.core.io.AbstractResource- 另请参阅:
-
StringUtils.applyRelativePath(String, String)
-
getName
This implementation returns the name of the file that this ServletContext resource refers to.- 指定者:
getName在接口中cn.taketoday.core.io.Resource- 覆盖:
getName在类中cn.taketoday.core.io.AbstractResource- 另请参阅:
-
StringUtils.getFilename(String)
-
toString
This implementation returns a description that includes the ServletContext resource location.- 指定者:
toString在接口中cn.taketoday.core.io.Resource- 覆盖:
toString在类中cn.taketoday.core.io.AbstractResource
-
getPathWithinContext
- 指定者:
getPathWithinContext在接口中cn.taketoday.core.io.ContextResource
-
equals
This implementation compares the underlying ServletContext resource locations.- 覆盖:
equals在类中cn.taketoday.core.io.AbstractResource
-
hashCode
public int hashCode()This implementation returns the hash code of the underlying ServletContext resource location.- 覆盖:
hashCode在类中cn.taketoday.core.io.AbstractResource
-