java.lang.Object | |||||
↳ | org.springframework.context.support.ApplicationObjectSupport | ||||
↳ | org.springframework.web.context.support.WebApplicationObjectSupport | ||||
↳ | org.springframework.web.servlet.view.AbstractView | ||||
↳ | org.springframework.web.servlet.view.AbstractUrlBasedView | ||||
↳ | org.springframework.web.servlet.view.InternalResourceView |
Known Direct Subclasses |
Known Indirect Subclasses |
Wrapper for a JSP or other resource within the same web application. Exposes model objects as request attributes and forwards the request to the specified resource URL using a javax.servlet.RequestDispatcher.
A URL for this view is supposed to specify a resource within the web
application, suitable for RequestDispatcher's forward
or
include
method.
If operating within an already included request or within a response that
has already been committed, this view will fall back to an include instead of
a forward. This can be enforced by calling response.flushBuffer()
(which will commit the response) before rendering the view.
Typical usage with InternalResourceViewResolver
looks as follows,
from the perspective of the DispatcherServlet context definition:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean>Every view name returned from a handler will be translated to a JSP resource (for example: "myView" -> "/WEB-INF/jsp/myView.jsp"), using this view class by default.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.view.AbstractView
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From interface
org.springframework.web.servlet.View
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor for use as a bean.
| |||||||||||
Create a new InternalResourceView with the given URL.
| |||||||||||
Create a new InternalResourceView with the given URL.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Specify whether to always include the view rather than forward to it.
| |||||||||||
Set whether to make all Spring beans in the application context accessible
as request attributes, through lazy checking once an attribute gets accessed.
| |||||||||||
Set whether to explictly expose the Servlet 2.4 forward request attributes
when forwarding to the underlying view resource.
| |||||||||||
Specify the names of beans in the context which are supposed to be exposed.
| |||||||||||
Set whether to explicitly prevent dispatching back to the
current handler path.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Expose the current request URI and paths as HttpServletRequest
attributes under the keys defined in the Servlet 2.4 specification,
for Servlet 2.3 containers as well as misbehaving Servlet 2.4 containers
(such as OC4J).
| |||||||||||
Expose helpers unique to each rendering operation.
| |||||||||||
Obtain the RequestDispatcher to use for the forward/include.
| |||||||||||
Get the request handle to expose to the RequestDispatcher, i.e.
| |||||||||||
Checks whether we need to explicitly expose the Servlet 2.4 request attributes
by default.
| |||||||||||
An ApplicationContext is not strictly required for InternalResourceView.
| |||||||||||
Prepare for rendering, and determine the request dispatcher path
to forward to (or to include).
| |||||||||||
Render the internal resource given the specified model.
| |||||||||||
Determine whether to use RequestDispatcher's
include or
forward method. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.view.AbstractUrlBasedView
| |||||||||||
From class
org.springframework.web.servlet.view.AbstractView
| |||||||||||
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanNameAware
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
| |||||||||||
From interface
org.springframework.web.servlet.View
|
Constructor for use as a bean.
Create a new InternalResourceView with the given URL.
url | the URL to forward to |
---|
Create a new InternalResourceView with the given URL.
url | the URL to forward to |
---|---|
alwaysInclude | whether to always include the view rather than forward to it |
Specify whether to always include the view rather than forward to it.
Default is "false". Switch this flag on to enforce the use of a Servlet include, even if a forward would be possible.
Set whether to make all Spring beans in the application context accessible as request attributes, through lazy checking once an attribute gets accessed.
This will make all such beans accessible in plain ${...}
expressions in a JSP 2.0 page, as well as in JSTL's c:out
value expressions.
Default is "false". Switch this flag on to transparently expose all Spring beans in the request attribute namespace.
NOTE: Context beans will override any custom request or session attributes of the same name that have been manually added. However, model attributes (as explicitly exposed to this view) of the same name will always override context beans.
Set whether to explictly expose the Servlet 2.4 forward request attributes when forwarding to the underlying view resource.
Default is "true" on Servlet containers up until 2.4, and "false" for Servlet 2.5 and above. Note that Servlet containers at 2.4 level and above should expose those attributes automatically! This InternalResourceView feature exists for Servlet 2.3 containers and misbehaving 2.4 containers.
Specify the names of beans in the context which are supposed to be exposed. If this is non-null, only the specified beans are eligible for exposure as attributes.
If you'd like to expose all Spring beans in the application context, switch
the "exposeContextBeansAsAttributes"
flag on but do not list specific bean names for this property.
Set whether to explicitly prevent dispatching back to the current handler path.
Default is "false". Switch this to "true" for convention-based views where a dispatch back to the current handler path is a definitive error.
Expose the current request URI and paths as HttpServletRequest attributes under the keys defined in the Servlet 2.4 specification, for Servlet 2.3 containers as well as misbehaving Servlet 2.4 containers (such as OC4J).
Does not expose the attributes on Servlet 2.5 or above, mainly for GlassFish compatibility (GlassFish gets confused by pre-exposed attributes). In any case, Servlet 2.5 containers should finally properly support Servlet 2.4 features, shouldn't they...
request | current HTTP request |
---|
Expose helpers unique to each rendering operation. This is necessary so that different rendering operations can't overwrite each other's contexts etc.
Called by renderMergedOutputModel(Map, HttpServletRequest, HttpServletResponse)
.
The default implementation is empty. This method can be overridden to add
custom helpers as request attributes.
request | current HTTP request |
---|
Exception | if there's a fatal error while we're adding attributes |
---|
Obtain the RequestDispatcher to use for the forward/include.
The default implementation simply calls
getRequestDispatcher(String)
.
Can be overridden in subclasses.
request | current HTTP request |
---|---|
path | the target URL (as returned from prepareForRendering(HttpServletRequest, HttpServletResponse) ) |
Get the request handle to expose to the RequestDispatcher, i.e. to the view.
The default implementation wraps the original request for exposure of Spring beans as request attributes (if demanded).
originalRequest | the original servlet request as provided by the engine |
---|
Checks whether we need to explicitly expose the Servlet 2.4 request attributes by default.
sc | the ServletContext that this application object runs in
(never null )
|
---|
An ApplicationContext is not strictly required for InternalResourceView.
Prepare for rendering, and determine the request dispatcher path to forward to (or to include).
This implementation simply returns the configured URL. Subclasses can override this to determine a resource to render, typically interpreting the URL in a different manner.
request | current HTTP request |
---|---|
response | current HTTP response |
Exception | if preparations failed |
---|
Render the internal resource given the specified model. This includes setting the model as request attributes.
model | combined output Map (never null ),
with dynamic values taking precedence over static attributes |
---|---|
request | current HTTP request |
response | current HTTP response |
Exception |
---|
Determine whether to use RequestDispatcher's include
or
forward
method.
Performs a check whether an include URI attribute is found in the request, indicating an include request, and whether the response has already been committed. In both cases, an include will be performed, as a forward is not possible anymore.
request | current HTTP request |
---|---|
response | current HTTP response |
true
for include, false
for forward