Top Description Fields Constructors Methods
org.springframework.web.servlet.view.xml

public Class MappingJackson2XmlView

extends AbstractJackson2View
Class Inheritance
Imports
java.util.Map, com.fasterxml.jackson.annotation.JsonView, com.fasterxml.jackson.dataformat.xml.XmlMapper, org.springframework.http.converter.json.Jackson2ObjectMapperBuilder, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.validation.BindingResult, org.springframework.web.servlet.View, org.springframework.web.servlet.view.json.AbstractJackson2View

Spring MVC View that renders XML content by serializing the model for the current request using Jackson 2's XmlMapper.

The Object to be serialized is supplied as a parameter in the model. The first serializable entry is used. Users can either specify a specific entry in the model via the sourceKey property.

The default constructor uses the default configuration provided by Jackson2ObjectMapperBuilder.

Author
Sebastien Deleuze
Since
4.1
See Also
org.springframework.web.servlet.view.json.MappingJackson2JsonView

Field Summary

Modifier and TypeField and Description
public static final String
private String
Inherited from org.springframework.web.servlet.view.json.AbstractJackson2View:
updateContentLength

Constructor Summary

AccessConstructor and Description
public
MappingJackson2XmlView()

Construct a new MappingJackson2XmlView using default configuration provided by Jackson2ObjectMapperBuilder and setting the content type to application/xml.

public
MappingJackson2XmlView(XmlMapper xmlMapper)

Construct a new MappingJackson2XmlView using the provided XmlMapper and setting the content type to application/xml.

Method Summary

Modifier and TypeMethod and Description
protected Object
filterModel(Map<String, Object>
the model, as passed on to renderMergedOutputModel
model
)

Implements abstract org.springframework.web.servlet.view.json.AbstractJackson2View.filterModel.

Filter out undesired attributes from the given model.

public void
setModelKey(String modelKey)

Implements abstract org.springframework.web.servlet.view.json.AbstractJackson2View.setModelKey.

Set the attribute in the model that should be rendered by this view.

Inherited from org.springframework.web.servlet.view.json.AbstractJackson2View:
filterAndWrapModelgetEncodinggetObjectMapperprepareResponserenderMergedOutputModelsetDisableCachingsetEncodingsetObjectMappersetPrettyPrintsetUpdateContentLengthwriteContentwritePrefixwriteSuffix

Field Detail

DEFAULT_CONTENT_TYPEback to summary
public static final String DEFAULT_CONTENT_TYPE

Hides org.springframework.web.servlet.view.AbstractView.DEFAULT_CONTENT_TYPE.

The default content type for the view.

modelKeyback to summary
private String modelKey
Annotations
@Nullable

Constructor Detail

MappingJackson2XmlViewback to summary
public MappingJackson2XmlView()

Construct a new MappingJackson2XmlView using default configuration provided by Jackson2ObjectMapperBuilder and setting the content type to application/xml.

MappingJackson2XmlViewback to summary
public MappingJackson2XmlView(XmlMapper xmlMapper)

Construct a new MappingJackson2XmlView using the provided XmlMapper and setting the content type to application/xml.

Since
4.2.1

Method Detail

filterModelback to summary
protected Object filterModel(Map<String, Object> model)

Implements abstract org.springframework.web.servlet.view.json.AbstractJackson2View.filterModel.

Doc from org.springframework.web.servlet.view.json.AbstractJackson2View.filterModel.

Filter out undesired attributes from the given model. The return value can be either another Map or a single value object.

Parameters
model:Map<String, Object>

the model, as passed on to renderMergedOutputModel

Returns:Object

the value to be rendered

Annotations
@Override
setModelKeyback to summary
public void setModelKey(String modelKey)

Implements abstract org.springframework.web.servlet.view.json.AbstractJackson2View.setModelKey.

Doc from org.springframework.web.servlet.view.json.AbstractJackson2View.setModelKey.

Set the attribute in the model that should be rendered by this view. When set, all other model attributes will be ignored.

Annotations
@Override