|
spring-web | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.core.io.AbstractResource
org.springframework.core.io.AbstractFileResolvingResource
org.springframework.web.context.support.ServletContextResource
public class ServletContextResource
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.
ServletContext.getResourceAsStream(java.lang.String),
ServletContext.getResource(java.lang.String),
ServletContext.getRealPath(java.lang.String)| Constructor Summary | |
|---|---|
ServletContextResource(javax.servlet.ServletContext servletContext,
java.lang.String path)
Create a new ServletContextResource. |
|
| Method Summary | |
|---|---|
org.springframework.core.io.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 obj)
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()
|
javax.servlet.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 |
isReadable()
This implementation delegates to ServletContext.getResourceAsStream,
which returns null in case of a non-readable resource (e.g. |
| Methods inherited from class org.springframework.core.io.AbstractFileResolvingResource |
|---|
contentLength, getFile, getFileForLastModifiedCheck, lastModified |
| Methods inherited from class org.springframework.core.io.AbstractResource |
|---|
getURI, isOpen, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.springframework.core.io.Resource |
|---|
contentLength, getURI, isOpen, lastModified |
| Constructor Detail |
|---|
public ServletContextResource(javax.servlet.ServletContext servletContext,
java.lang.String path)
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| Method Detail |
|---|
public final javax.servlet.ServletContext getServletContext()
public final java.lang.String getPath()
public boolean exists()
ServletContext.getResource.
exists in interface org.springframework.core.io.Resourceexists in class org.springframework.core.io.AbstractFileResolvingResourceServletContext.getResource(String)public boolean isReadable()
ServletContext.getResourceAsStream,
which returns null in case of a non-readable resource (e.g. a directory).
isReadable in interface org.springframework.core.io.ResourceisReadable in class org.springframework.core.io.AbstractFileResolvingResourceServletContext.getResourceAsStream(String)
public java.io.InputStream getInputStream()
throws java.io.IOException
ServletContext.getResourceAsStream,
but throws a FileNotFoundException if no resource found.
getInputStream in interface org.springframework.core.io.InputStreamSourcegetInputStream in interface org.springframework.core.io.Resourcejava.io.IOExceptionServletContext.getResourceAsStream(String)
public java.net.URL getURL()
throws java.io.IOException
ServletContext.getResource,
but throws a FileNotFoundException if no resource found.
getURL in interface org.springframework.core.io.ResourcegetURL in class org.springframework.core.io.AbstractResourcejava.io.IOExceptionServletContext.getResource(String)
public java.io.File getFile()
throws java.io.IOException
ServletContext.getRealPath, throwing a FileNotFoundException
if not found or not resolvable.
getFile in interface org.springframework.core.io.ResourcegetFile in class org.springframework.core.io.AbstractFileResolvingResourcejava.io.IOExceptionServletContext.getResource(String),
ServletContext.getRealPath(String)public org.springframework.core.io.Resource createRelative(java.lang.String relativePath)
createRelative in interface org.springframework.core.io.ResourcecreateRelative in class org.springframework.core.io.AbstractResourceStringUtils.applyRelativePath(String, String)public java.lang.String getFilename()
getFilename in interface org.springframework.core.io.ResourcegetFilename in class org.springframework.core.io.AbstractResourceStringUtils.getFilename(String)public java.lang.String getDescription()
getDescription in interface org.springframework.core.io.Resourcepublic java.lang.String getPathWithinContext()
getPathWithinContext in interface org.springframework.core.io.ContextResourcepublic boolean equals(java.lang.Object obj)
equals in class org.springframework.core.io.AbstractResourcepublic int hashCode()
hashCode in class org.springframework.core.io.AbstractResource
|
spring-web | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||