spring-framework / org.springframework.core.io / ContextResource

ContextResource

interface ContextResource : Resource

Extended interface for a resource that is loaded from an enclosing 'context', e.g. from a javax.servlet.ServletContext but also from plain classpath paths or relative file system paths (specified without an explicit prefix, hence applying relative to the local ResourceLoader's context).

Author
Juergen Hoeller

Since
2.5

See Also
org.springframework.web.context.support.ServletContextResource

Functions

getPathWithinContext

abstract fun getPathWithinContext(): String

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.

Inheritors

ServletContextResource

open class ServletContextResource : AbstractFileResolvingResource, ContextResource

org.springframework.core.io.Resource implementation for javax.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.