org.springframework.web.context.support
Class ServletContextResource
org.springframework.core.io.AbstractResource
|
+--org.springframework.web.context.support.ServletContextResource
- public class ServletContextResource
- extends AbstractResource
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.
- Author:
- Juergen Hoeller
- Since: 28.12.2003
- See Also: javax.servlet.ServletContext#getResourceAsStream, javax.servlet.ServletContext#getRealPath
Constructor Summary |
ServletContextResource(ServletContext servletContext, String path) Create a new ServletContextResource. |
Method Summary |
String | getDescription() |
File | getFile() This implementation delegates to ServletContext.getRealPath,
but throws a FileNotFoundException if not found or not resolvable. |
InputStream | getInputStream() This implementation delegates to ServletContext.getResourceAsStream,
but throws a FileNotFoundException if not found. |
ServletContextResource
public ServletContextResource(ServletContext servletContext, String path)
- Create a new ServletContextResource.
- Parameters:
- servletContext - the ServletContext to load from
- path - the path of the resource
getDescription
public String getDescription()
getFile
public File getFile()
throws java.io.IOException
- This implementation delegates to ServletContext.getRealPath,
but throws a FileNotFoundException if not found or not resolvable.
- See Also:
- javax.servlet.ServletContext#getRealPath
getInputStream
public InputStream getInputStream()
throws java.io.IOException
- This implementation delegates to ServletContext.getResourceAsStream,
but throws a FileNotFoundException if not found.
- See Also:
- javax.servlet.ServletContext#getResourceAsStream
to Class java.lang.String