public class MarshallingView extends AbstractView
View that allows for response context to be rendered as the result of marshalling by a <code>Marshaller</code>.
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 Spring locate the Source object.
| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_CONTENT_TYPE
Default content type.
|
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE| Constructor and Description |
|---|
MarshallingView()
Constructs a new
MarshallingView with no <code>Marshaller</code> set. |
MarshallingView(org.springframework.oxm.Marshaller marshaller)
Constructs a new
MarshallingView with the given <code>Marshaller</code> set. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
initApplicationContext() |
protected Object |
locateToBeMarshalled(Map<String,Object> model)
Locates the object to be marshalled.
|
protected void |
renderMergedOutputModel(Map<String,Object> model,
HttpServletRequest request,
HttpServletResponse response)
Subclasses must implement this method to actually render the view.
|
void |
setMarshaller(org.springframework.oxm.Marshaller marshaller)
Sets the <code>Marshaller</code> to be used by this view.
|
void |
setModelKey(String modelKey)
Set the name of the model key that represents the object to be marshalled.
|
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposePathVariables, setRequestContextAttribute, setResponseContentType, toString, writeToResponsegetServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContextpublic static final String DEFAULT_CONTENT_TYPE
public MarshallingView()
MarshallingView with no <code>Marshaller</code> set. The marshaller must be set after
construction by invoking setMarshaller(Marshaller).public MarshallingView(org.springframework.oxm.Marshaller marshaller)
MarshallingView with the given <code>Marshaller</code> set.public void setMarshaller(org.springframework.oxm.Marshaller marshaller)
public void setModelKey(String modelKey)
Marshaller.supports(Class)protected void initApplicationContext()
throws org.springframework.beans.BeansException
initApplicationContext in class org.springframework.context.support.ApplicationObjectSupportorg.springframework.beans.BeansExceptionprotected void renderMergedOutputModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception
AbstractViewThe 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 in class AbstractViewmodel - combined output Map (never null),
with dynamic values taking precedence over static attributesrequest - current HTTP requestresponse - current HTTP responseException - if rendering failedprotected Object locateToBeMarshalled(Map<String,Object> model) throws ServletException
model - the model Mapnull if none found)ServletException - if the model object specified by the model key is not
supported by the marshallersetModelKey(String)