org.springframework.core.io.Resource implementation for
jakarta.servlet.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.
jakarta.servlet.ServletContext#getResourceAsStream , jakarta.servlet.ServletContext#getResource , jakarta.servlet.ServletContext#getRealPath
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final ServletContext |
| Access | Constructor and Description |
|---|---|
| public | ServletContextResource(ServletContext
the ServletContext to load from servletContext, String the path of the resource path)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public Resource | createRelative(String
the relative path (relative to this resource) relativePath)Overrides org. Implements org. This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor. |
| public boolean | equals(Object
the reference object with which to compare. other)Overrides org. This implementation compares the underlying ServletContext resource locations. |
| public boolean | exists()
Overrides org. Implements org. This implementation checks |
| public String | getDescription()
Implements org. This implementation returns a description that includes the ServletContext resource location. |
| public File | getFile()
Overrides org. Implements org. This implementation resolves "file:" URLs or alternatively delegates to
|
| public String | getFilename()
Overrides org. Implements org. This implementation returns the name of the file that this ServletContext resource refers to. |
| public InputStream | getInputStream()
Implements org. This implementation delegates to |
| public final String | |
| public String | getPathWithinContext()
Implements org. Return the path within the enclosing 'context'. |
| public final ServletContext | |
| public URL | getURL()
Overrides org. Implements org. This implementation delegates to |
| public int | hashCode()
Overrides org. This implementation returns the hash code of the underlying ServletContext resource location. |
| public boolean | isFile()
Overrides org. Overrides default org. Determine whether this resource represents a file in a file system. |
| public boolean | isReadable()
Overrides org. Overrides default org. This implementation delegates to |
| path | back to summary |
|---|---|
| private final String path | |
| servletContext | back to summary |
|---|---|
| private final ServletContext servletContext | |
| ServletContextResource | back to summary |
|---|---|
| public ServletContextResource(ServletContext servletContext, String path) Create a new 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.
| |
| createRelative | back to summary |
|---|---|
| public Resource createRelative(String relativePath) Overrides org. Implements org. This implementation creates a ServletContextResource, applying the given path relative to the path of the underlying file of this resource descriptor.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides org. This implementation compares the underlying ServletContext resource locations.
| |
| exists | back to summary |
|---|---|
| public boolean exists() Overrides org. Implements org. This implementation checks
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Implements org. This implementation returns a description that includes the ServletContext resource location.
| |
| getFile | back to summary |
|---|---|
| public File getFile() throws IOException Overrides org. Implements org. This implementation resolves "file:" URLs or alternatively delegates to
| |
| getFilename | back to summary |
|---|---|
| public String getFilename() Overrides org. Implements org. This implementation returns the name of the file that this ServletContext resource refers to.
| |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream() throws IOException Implements org. This implementation delegates to
| |
| getPath | back to summary |
|---|---|
| public final String getPath() Return the path for this resource. | |
| getPathWithinContext | back to summary |
|---|---|
| public String getPathWithinContext() Implements org. Doc from org. Return the path within the enclosing 'context'. This is typically path relative to a context-specific root directory, e.g. a ServletContext root or a PortletContext root.
| |
| getServletContext | back to summary |
|---|---|
| public final ServletContext getServletContext() Return the ServletContext for this resource. | |
| getURL | back to summary |
|---|---|
| public URL getURL() throws IOException Overrides org. Implements org. This implementation delegates to
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides org. This implementation returns the hash code of the underlying ServletContext resource location.
| |
| isFile | back to summary |
|---|---|
| public boolean isFile() Overrides org. Overrides default org. Doc from org. Determine whether this resource represents a file in a file system. A value of This is conservatively
| |
| isReadable | back to summary |
|---|---|
| public boolean isReadable() Overrides org. Overrides default org. This implementation delegates to
| |