jakarta.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.
jakarta.servlet.RequestDispatcher#forward , jakarta.servlet.RequestDispatcher#include , jakarta.servlet.ServletResponse#flushBuffer , InternalResourceViewResolver, JstlView
| Modifier and Type | Field and Description |
|---|---|
| private boolean | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | InternalResourceView(String
the URL to forward to url)Create a new InternalResourceView with the given URL. |
| public | InternalResourceView(String
the URL to forward to url, boolean whether to always include the view rather than forward to it alwaysInclude)Create a new InternalResourceView with the given URL. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | exposeHelpers(HttpServletRequest
current HTTP request request)Expose helpers unique to each rendering operation. |
| protected RequestDispatcher | Returns: a corresponding RequestDispatchercurrent HTTP request request, String the target URL (as returned from path)prepareForRendering)Obtain the RequestDispatcher to use for the forward/include. |
| protected boolean | isContextRequired()
Overrides org. An ApplicationContext is not strictly required for InternalResourceView. |
| protected String | Returns: the request dispatcher path to usecurrent HTTP request request, HttpServletResponse current HTTP response response)Prepare for rendering, and determine the request dispatcher path to forward to (or to include). |
| protected void | renderMergedOutputModel(Map<String, Object>
combined output Map (never model, HttpServletRequest null),
with dynamic values taking precedence over static attributescurrent HTTP request request, HttpServletResponse current HTTP response response)Implements abstract org. Render the internal resource given the specified model. |
| public void | setAlwaysInclude(boolean alwaysInclude)
Specify whether to always include the view rather than forward to it. |
| public void | setPreventDispatchLoop(boolean preventDispatchLoop)
Set whether to explicitly prevent dispatching back to the current handler path. |
| protected boolean | Returns: true for include, false for forwardcurrent HTTP request request, HttpServletResponse current HTTP response response)Determine whether to use RequestDispatcher's |
| alwaysInclude | back to summary |
|---|---|
| private boolean alwaysInclude | |
| preventDispatchLoop | back to summary |
|---|---|
| private boolean preventDispatchLoop | |
| InternalResourceView | back to summary |
|---|---|
| public InternalResourceView() Constructor for use as a bean.
| |
| InternalResourceView | back to summary |
|---|---|
| public InternalResourceView(String url) Create a new InternalResourceView with the given URL.
| |
| InternalResourceView | back to summary |
|---|---|
| public InternalResourceView(String url, boolean alwaysInclude) Create a new InternalResourceView with the given URL.
| |
| exposeHelpers | back to summary |
|---|---|
| protected void exposeHelpers(HttpServletRequest request) throws Exception 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
| |
| getRequestDispatcher | back to summary |
|---|---|
| protected RequestDispatcher getRequestDispatcher(HttpServletRequest request, String path) Obtain the RequestDispatcher to use for the forward/include. The default implementation simply calls
| |
| isContextRequired | back to summary |
|---|---|
| protected boolean isContextRequired() Overrides org. An ApplicationContext is not strictly required for InternalResourceView.
| |
| prepareForRendering | back to summary |
|---|---|
| protected String prepareForRendering(HttpServletRequest request, HttpServletResponse response) throws Exception 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.
| |
| setAlwaysInclude | back to summary |
|---|---|
| public void setAlwaysInclude(boolean alwaysInclude) 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. | |
| setPreventDispatchLoop | back to summary |
|---|---|
| public void setPreventDispatchLoop(boolean preventDispatchLoop) 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. | |
| useInclude | back to summary |
|---|---|
| protected boolean useInclude(HttpServletRequest request, HttpServletResponse response) Determine whether to use RequestDispatcher's 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.
| |