类 MarshallingView
java.lang.Object
cn.taketoday.context.support.ApplicationObjectSupport
cn.taketoday.web.view.AbstractView
cn.taketoday.web.view.xml.MarshallingView
- 所有已实现的接口:
cn.taketoday.beans.factory.Aware,cn.taketoday.beans.factory.BeanNameAware,cn.taketoday.context.ApplicationContextAware,View
Web-MVC
View that allows for response context to be rendered as the result
of marshalling by a Marshaller.
The Object to be marshalled is supplied as a parameter in the model and then
detected during response rendering. Users can
either specify a specific entry in the model via the sourceKey
property or have Infra locate the Source object.
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma, Juergen Hoeller
-
字段概要
字段修饰符和类型字段说明static final StringDefault content type.private cn.taketoday.oxm.Marshallerprivate String从类继承的字段 cn.taketoday.context.support.ApplicationObjectSupport
applicationContext, log, messageSourceAccessor从接口继承的字段 cn.taketoday.web.view.View
RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
构造器概要
构造器构造器说明Construct a newMarshallingViewwith noMarshallerset.MarshallingView(cn.taketoday.oxm.Marshaller marshaller) Constructs a newMarshallingViewwith the givenMarshallerset. -
方法概要
修饰符和类型方法说明protected voidprotected booleanisEligibleForMarshalling(String modelKey, Object value) Check whether the given value from the current view's model is eligible for marshalling through the configuredMarshaller.protected ObjectlocateToBeMarshalled(Map<String, Object> model) Locate the object to be marshalled.protected voidrenderMergedOutputModel(Map<String, Object> model, RequestContext request) Subclasses must implement this method to actually render the view.voidsetMarshaller(cn.taketoday.oxm.Marshaller marshaller) Set theMarshallerto be used by this view.voidsetModelKey(String modelKey) Set the name of the model key that represents the object to be marshalled.从类继承的方法 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, toString, writeToResponse从类继承的方法 cn.taketoday.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext, unwrapContext, unwrapFactory
-
字段详细资料
-
DEFAULT_CONTENT_TYPE
Default content type. Overridable as bean property.- 另请参阅:
-
marshaller
@Nullable private cn.taketoday.oxm.Marshaller marshaller -
modelKey
-
-
构造器详细资料
-
MarshallingView
public MarshallingView()Construct a newMarshallingViewwith noMarshallerset. The marshaller must be set after construction by invokingsetMarshaller(cn.taketoday.oxm.Marshaller). -
MarshallingView
public MarshallingView(cn.taketoday.oxm.Marshaller marshaller) Constructs a newMarshallingViewwith the givenMarshallerset.
-
-
方法详细资料
-
setMarshaller
public void setMarshaller(cn.taketoday.oxm.Marshaller marshaller) Set theMarshallerto be used by this view. -
setModelKey
Set the name of the model key that represents the object to be marshalled. If not specified, the model map will be searched for a supported value type.- 另请参阅:
-
Marshaller.supports(Class)
-
initApplicationContext
protected void initApplicationContext()- 覆盖:
initApplicationContext在类中cn.taketoday.context.support.ApplicationObjectSupport
-
renderMergedOutputModel
protected void renderMergedOutputModel(Map<String, Object> model, RequestContext request) throws Exception从类复制的说明:AbstractViewSubclasses 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 request context- 抛出:
Exception- if rendering failed
-
locateToBeMarshalled
@Nullable protected Object locateToBeMarshalled(Map<String, Object> model) throws IllegalStateExceptionLocate the object to be marshalled.The default implementation first attempts to look under the configured model key, if any, before attempting to locate an object of supported type.
- 参数:
model- the model Map- 返回:
- the Object to be marshalled (or
nullif none found) - 抛出:
IllegalStateException- if the model object specified by the model key is not supported by the marshaller- 另请参阅:
-
isEligibleForMarshalling
Check whether the given value from the current view's model is eligible for marshalling through the configuredMarshaller.The default implementation calls
Marshaller.supports(Class), unwrapping a givenJAXBElementfirst if applicable.- 参数:
modelKey- the value's key in the model (nevernull)value- the value to check (nevernull)- 返回:
- whether the given value is to be considered as eligible
- 另请参阅:
-
Marshaller.supports(Class)
-