类 AbstractTemplateView
- 直接已知子类:
FreeMarkerView
,GroovyMarkupView
,VelocityView
public abstract class AbstractTemplateView extends AbstractUrlBasedView
Adapter base class for template-based view technologies such as Velocity and FreeMarker, with the ability to use request and session attributes in their model and the option to expose helper objects for Spring's Velocity/FreeMarker macro library.JSP/JSTL and other view technologies automatically have access to the HttpServletRequest object and thereby the request/session attributes for the current user. Furthermore, they are able to create and cache helper objects as request attributes themselves.
- 从以下版本开始:
- 1.0.2
- 作者:
- Juergen Hoeller, Darren Davison
- 另请参阅:
AbstractTemplateViewResolver
,VelocityView
,FreeMarkerView
字段概要
字段 修饰符和类型 字段 说明 static String
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Variable name of the RequestContext instance in the template model, available to Spring's macros: e.g. for creating BindStatus objects.从类继承的字段 org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPE
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
构造器概要
构造器 构造器 说明 AbstractTemplateView()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected void
applyContentType(HttpServletResponse response)
Apply this view's content type as specified in the "contentType" bean property to the given response.protected void
renderMergedOutputModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response)
Subclasses must implement this method to actually render the view.protected abstract void
renderMergedTemplateModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response)
Subclasses must implement this method to actually render the view.void
setAllowRequestOverride(boolean allowRequestOverride)
Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name.void
setAllowSessionOverride(boolean allowSessionOverride)
Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name.void
setExposeRequestAttributes(boolean exposeRequestAttributes)
Set whether all request attributes should be added to the model prior to merging with the template.void
setExposeSessionAttributes(boolean exposeSessionAttributes)
Set whether all HttpSession attributes should be added to the model prior to merging with the template.void
setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers)
Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext".从类继承的方法 org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, checkResource, getUrl, isUrlRequired, setUrl, toString
从类继承的方法 org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
字段详细资料
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
public static final String SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Variable name of the RequestContext instance in the template model, available to Spring's macros: e.g. for creating BindStatus objects.- 另请参阅:
- 常量字段值
构造器详细资料
AbstractTemplateView
public AbstractTemplateView()
方法详细资料
setExposeRequestAttributes
public void setExposeRequestAttributes(boolean exposeRequestAttributes)
Set whether all request attributes should be added to the model prior to merging with the template. Default is "false".
setAllowRequestOverride
public void setAllowRequestOverride(boolean allowRequestOverride)
Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. Default is "false", which causes an exception to be thrown if request attributes of the same name as model attributes are found.
setExposeSessionAttributes
public void setExposeSessionAttributes(boolean exposeSessionAttributes)
Set whether all HttpSession attributes should be added to the model prior to merging with the template. Default is "false".
setAllowSessionOverride
public void setAllowSessionOverride(boolean allowSessionOverride)
Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. Default is "false", which causes an exception to be thrown if session attributes of the same name as model attributes are found.
setExposeSpringMacroHelpers
public void setExposeSpringMacroHelpers(boolean exposeSpringMacroHelpers)
Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". Default is "true".Currently needed for Spring's Velocity and FreeMarker default macros. Note that this is not required for templates that use HTML forms unless you wish to take advantage of the Spring helper macros.
renderMergedOutputModel
protected final void renderMergedOutputModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception
从类复制的说明:AbstractView
Subclasses must implement this method to actually render the view.The first step will be preparing the request: In the JSP case, this would mean setting model objects as request attributes. The second step will be the actual rendering of the view, for example including the JSP via a RequestDispatcher.
- 指定者:
renderMergedOutputModel
在类中AbstractView
- 参数:
model
- combined output Map (nevernull
), with dynamic values taking precedence over static attributesrequest
- current HTTP requestresponse
- current HTTP response- 抛出:
Exception
- if rendering failed
applyContentType
protected void applyContentType(HttpServletResponse response)
Apply this view's content type as specified in the "contentType" bean property to the given response.Only applies the view's contentType if no content type has been set on the response before. This allows handlers to override the default content type beforehand.
- 参数:
response
- current HTTP response- 另请参阅:
AbstractView.setContentType(java.lang.String)
renderMergedTemplateModel
protected abstract void renderMergedTemplateModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception
Subclasses must implement this method to actually render the view.- 参数:
model
- combined output Map, with request attributes and session attributes merged into it if requiredrequest
- current HTTP requestresponse
- current HTTP response- 抛出:
Exception
- if rendering failed