public class ServletContextResource
extends org.springframework.core.io.AbstractFileResolvingResource
implements org.springframework.core.io.ContextResource
| Constructor and Description |
|---|
ServletContextResource(javax.servlet.ServletContext servletContext,
String path)
Create a new ServletContextResource.
|
| Modifier and Type | Method and Description |
|---|---|
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()
This implementation delegates to
ServletContext.getRealPath,
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() |
javax.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.
|
contentLength, customizeConnection, customizeConnection, getFile, getFileForLastModifiedCheck, isReadable, lastModifiedpublic ServletContextResource(javax.servlet.ServletContext servletContext,
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 resourcepublic final javax.servlet.ServletContext getServletContext()
public final 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 InputStream getInputStream() throws IOException
ServletContext.getResourceAsStream,
but throws a FileNotFoundException if no resource found.getInputStream in interface org.springframework.core.io.InputStreamSourceIOExceptionServletContext.getResourceAsStream(String)public URL getURL() throws 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.AbstractResourceIOExceptionServletContext.getResource(String)public File getFile() throws IOException
ServletContext.getRealPath,
but throws a FileNotFoundException if not found or not resolvable.getFile in interface org.springframework.core.io.ResourcegetFile in class org.springframework.core.io.AbstractFileResolvingResourceIOExceptionServletContext.getRealPath(String)public org.springframework.core.io.Resource createRelative(String relativePath)
createRelative in interface org.springframework.core.io.ResourcecreateRelative in class org.springframework.core.io.AbstractResourcepublic String getFilename()
getFilename in interface org.springframework.core.io.ResourcegetFilename in class org.springframework.core.io.AbstractResourcepublic String getDescription()
getDescription in interface org.springframework.core.io.Resourcepublic String getPathWithinContext()
getPathWithinContext in interface org.springframework.core.io.ContextResourcepublic boolean equals(Object obj)
equals in class org.springframework.core.io.AbstractResourcepublic int hashCode()
hashCode in class org.springframework.core.io.AbstractResourceCopyright © 2005–2019 The Beangle Software. All rights reserved.