类 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

public class MarshallingView extends AbstractView
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
  • 字段详细资料

    • DEFAULT_CONTENT_TYPE

      public static final String DEFAULT_CONTENT_TYPE
      Default content type. Overridable as bean property.
      另请参阅:
    • marshaller

      @Nullable private cn.taketoday.oxm.Marshaller marshaller
    • modelKey

      @Nullable private String modelKey
  • 构造器详细资料

    • MarshallingView

      public MarshallingView()
      Construct a new MarshallingView with no Marshaller set. The marshaller must be set after construction by invoking setMarshaller(cn.taketoday.oxm.Marshaller).
    • MarshallingView

      public MarshallingView(cn.taketoday.oxm.Marshaller marshaller)
      Constructs a new MarshallingView with the given Marshaller set.
  • 方法详细资料

    • setMarshaller

      public void setMarshaller(cn.taketoday.oxm.Marshaller marshaller)
      Set the Marshaller to be used by this view.
    • setModelKey

      public void setModelKey(String modelKey)
      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
      从类复制的说明: 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 (never null), with dynamic values taking precedence over static attributes
      request - current HTTP request context
      抛出:
      Exception - if rendering failed
    • locateToBeMarshalled

      @Nullable protected Object locateToBeMarshalled(Map<String,Object> model) throws IllegalStateException
      Locate 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 null if none found)
      抛出:
      IllegalStateException - if the model object specified by the model key is not supported by the marshaller
      另请参阅:
    • isEligibleForMarshalling

      protected boolean isEligibleForMarshalling(String modelKey, Object value)
      Check whether the given value from the current view's model is eligible for marshalling through the configured Marshaller.

      The default implementation calls Marshaller.supports(Class), unwrapping a given JAXBElement first if applicable.

      参数:
      modelKey - the value's key in the model (never null)
      value - the value to check (never null)
      返回:
      whether the given value is to be considered as eligible
      另请参阅:
      • Marshaller.supports(Class)