|
|||||||||||
| 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.web.context.support.ServletContextResource
Resource implementation for ServletContext resources, interpreting relative paths within the web application root.
Always supports stream access, but only allows java.io.File access when the web application archive is expanded. Always supports resolution as URL.
ServletContext.getResourceAsStream(java.lang.String),
ServletContext.getRealPath(java.lang.String)| Field Summary |
| Fields inherited from class org.springframework.core.io.AbstractResource |
URL_PROTOCOL_FILE |
| Constructor Summary | |
ServletContextResource(javax.servlet.ServletContext servletContext,
java.lang.String path)
Create a new ServletContextResource. |
|
| Method Summary | |
Resource |
createRelative(java.lang.String relativePath)
This implementation throws a FileNotFoundException, assuming that relative resources cannot be created for this resource. |
boolean |
equals(java.lang.Object obj)
This implementation compares description strings. |
java.lang.String |
getDescription()
Return a description for this resource, to be used for error output when working with the resource. |
java.io.File |
getFile()
This implementation delegates to ServletContext.getRealPath, but throws a FileNotFoundException if not found or not resolvable. |
java.lang.String |
getFilename()
This implementation always throws IllegalStateException, assuming that the resource does not carry a filename. |
java.io.InputStream |
getInputStream()
This implementation delegates to ServletContext.getResourceAsStream, but throws a FileNotFoundException if not found. |
java.net.URL |
getURL()
This implementation throws a FileNotFoundException, assuming that the resource cannot be resolved to a URL. |
int |
hashCode()
This implementation returns the description's hash code. |
| Methods inherited from class org.springframework.core.io.AbstractResource |
exists, isOpen, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| 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 java.io.InputStream getInputStream()
throws java.io.IOException
java.io.IOException - if the stream could not be openedServletContext.getResourceAsStream(java.lang.String)
public java.net.URL getURL()
throws java.io.IOException
AbstractResource
getURL in interface ResourcegetURL in class AbstractResourcejava.io.IOException
public java.io.File getFile()
throws java.io.IOException
getFile in interface ResourcegetFile in class AbstractResourcejava.io.IOExceptionServletContext.getRealPath(java.lang.String)
public Resource createRelative(java.lang.String relativePath)
throws java.io.IOException
AbstractResource
createRelative in interface ResourcecreateRelative in class AbstractResourcejava.io.IOExceptionpublic java.lang.String getFilename()
AbstractResource
getFilename in interface ResourcegetFilename in class AbstractResourcepublic java.lang.String getDescription()
ResourceImplementations are also encouraged to return this value from their toString method.
Object.toString()public boolean equals(java.lang.Object obj)
AbstractResource
equals in class AbstractResourceResource.getDescription()public int hashCode()
AbstractResource
hashCode in class AbstractResourceResource.getDescription()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||