类 InternalResourceView
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.beans.factory.InitializingBean,cn.taketoday.context.ApplicationContextAware,ServletContextAware,View
- 直接已知子类:
JstlView
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="cn.taketoday.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.
- 从以下版本开始:
- 4.0
- 作者:
- Rod Johnson, Juergen Hoeller, Rob Harrop
- 另请参阅:
-
字段概要
字段从类继承的字段 cn.taketoday.web.view.AbstractView
DEFAULT_CONTENT_TYPE从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.view.View
RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
构造器概要
构造器构造器说明Constructor for use as a bean.Create a new InternalResourceView with the given URL.InternalResourceView(String url, boolean alwaysInclude) Create a new InternalResourceView with the given URL. -
方法概要
修饰符和类型方法说明protected voidexposeHelpers(HttpServletRequest servletRequest, RequestContext request) Expose helpers unique to each rendering operation.protected RequestDispatchergetRequestDispatcher(HttpServletRequest request, String path) Obtain the RequestDispatcher to use for the forward/include.protected voidinitServletContext(ServletContext servletContext) protected booleanAn ApplicationContext is not strictly required for InternalResourceView.protected StringprepareForRendering(HttpServletRequest request, HttpServletResponse response) Prepare for rendering, and determine the request dispatcher path to forward to (or to include).protected voidrenderMergedOutputModel(Map<String, Object> model, RequestContext request) Render the internal resource given the specified model.voidsetAlwaysInclude(boolean alwaysInclude) Specify whether to always include the view rather than forward to it.voidsetPreventDispatchLoop(boolean preventDispatchLoop) Set whether to explicitly prevent dispatching back to the current handler path.final voidsetServletContext(ServletContext servletContext) Set theServletContextthat this object runs in.protected booleanuseInclude(HttpServletRequest request, HttpServletResponse response) Determine whether to use RequestDispatcher'sincludeorforwardmethod.从类继承的方法 cn.taketoday.web.view.AbstractUrlBasedView
afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toString从类继承的方法 cn.taketoday.web.view.AbstractView
addStaticAttribute, createMergedOutputModel, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestContextToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposeOutputRedirectModel, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
servletContext
-
alwaysInclude
private boolean alwaysInclude -
preventDispatchLoop
private boolean preventDispatchLoop
-
-
构造器详细资料
-
InternalResourceView
public InternalResourceView()Constructor for use as a bean. -
InternalResourceView
Create a new InternalResourceView with the given URL.- 参数:
url- the URL to forward to- 另请参阅:
-
InternalResourceView
Create a new InternalResourceView with the given URL.- 参数:
url- the URL to forward toalwaysInclude- whether to always include the view rather than forward to it
-
-
方法详细资料
-
setAlwaysInclude
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
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.
-
isContextRequired
protected boolean isContextRequired()An ApplicationContext is not strictly required for InternalResourceView.- 覆盖:
isContextRequired在类中cn.taketoday.context.support.ApplicationObjectSupport
-
renderMergedOutputModel
protected void renderMergedOutputModel(Map<String, Object> model, RequestContext request) throws ExceptionRender the internal resource given the specified model. This includes setting the model as request attributes.- 指定者:
renderMergedOutputModel在类中AbstractView- 参数:
model- combined output Map (nevernull), with dynamic values taking precedence over static attributesrequest- current HTTP request context- 抛出:
Exception- if rendering failed
-
exposeHelpers
protected void exposeHelpers(HttpServletRequest servletRequest, RequestContext 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
renderMergedOutputModel(Map, RequestContext). 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- 另请参阅:
-
prepareForRendering
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.
- 参数:
request- current HTTP requestresponse- current HTTP response- 返回:
- the request dispatcher path to use
- 抛出:
Exception- if preparations failed- 另请参阅:
-
getRequestDispatcher
Obtain the RequestDispatcher to use for the forward/include.The default implementation simply calls
ServletRequest.getRequestDispatcher(String). Can be overridden in subclasses.- 参数:
request- current HTTP requestpath- the target URL (as returned fromprepareForRendering(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse))- 返回:
- a corresponding RequestDispatcher
-
useInclude
Determine whether to use RequestDispatcher'sincludeorforwardmethod.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 requestresponse- current HTTP response- 返回:
truefor include,falsefor forward- 另请参阅:
-
setServletContext
从接口复制的说明:ServletContextAwareSet theServletContextthat this object runs in.Invoked after population of normal bean properties but before an init callback like InitializingBean's
afterPropertiesSetor a custom init-method. Invoked after ApplicationContextAware'ssetApplicationContext.- 指定者:
setServletContext在接口中ServletContextAware- 参数:
servletContext- the ServletContext object to be used by this object- 另请参阅:
-
InitializingBean.afterPropertiesSet()ApplicationContextAware.setApplicationContext(cn.taketoday.context.ApplicationContext)
-
initServletContext
-
getServletContext
-