Top Description Fields Constructors Methods
org.springframework.http.converter.xml

public Class MappingJackson2XmlHttpMessageConverter

extends AbstractJackson2HttpMessageConverter
Class Inheritance
Imports
java.nio.charset.StandardCharsets, java.util.Collections, .List, com.fasterxml.jackson.databind.ObjectMapper, com.fasterxml.jackson.dataformat.xml.XmlMapper, org.springframework.http.MediaType, org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter, .Jackson2ObjectMapperBuilder, org.springframework.util.Assert

Implementation of HttpMessageConverter that can read and write XML using Jackson 2.x extension component for reading and writing XML encoded data.

By default, this converter supports application/xml, text/xml, and application/*+xml with UTF-8 character set. This can be overridden by setting the supportedMediaTypes property.

The default constructor uses the default configuration provided by Jackson2ObjectMapperBuilder.

Author
Sebastien Deleuze
Since
4.1

Field Summary

Modifier and TypeField and Description
private static final List<MediaType>
Inherited from org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter:
defaultObjectMapper

Constructor Summary

AccessConstructor and Description
public
MappingJackson2XmlHttpMessageConverter()

Construct a new MappingJackson2XmlHttpMessageConverter using default configuration provided by Jackson2ObjectMapperBuilder.

public
MappingJackson2XmlHttpMessageConverter(ObjectMapper objectMapper)

Construct a new MappingJackson2XmlHttpMessageConverter with a custom ObjectMapper (must be a XmlMapper instance).

Method Summary

Modifier and TypeMethod and Description
protected List<MediaType>
public void
setObjectMapper(ObjectMapper objectMapper)

Overrides org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.setObjectMapper.

Configure the main ObjectMapper to use for Object conversion.
Inherited from org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter:
canReadcanReadcanWritecustomizeReadercustomizeWritergetCharsetgetContentLengthgetDefaultContentTypegetJavaTypegetJsonEncodinggetObjectMappergetObjectMappersForTypegetSupportedMediaTypeslogWarningIfNecessaryreadreadInternalregisterObjectMappersForTypesetPrettyPrintsetSupportedMediaTypessupportsRepeatableWriteswriteInternalwritePrefixwriteSuffix

Field Detail

problemDetailMediaTypesback to summary
private static final List<MediaType> problemDetailMediaTypes

Constructor Detail

MappingJackson2XmlHttpMessageConverterback to summary
public MappingJackson2XmlHttpMessageConverter()

Construct a new MappingJackson2XmlHttpMessageConverter using default configuration provided by Jackson2ObjectMapperBuilder.

MappingJackson2XmlHttpMessageConverterback to summary
public MappingJackson2XmlHttpMessageConverter(ObjectMapper objectMapper)

Construct a new MappingJackson2XmlHttpMessageConverter with a custom ObjectMapper (must be a XmlMapper instance). You can use Jackson2ObjectMapperBuilder to build it easily.

See Also
Jackson2ObjectMapperBuilder#xml()

Method Detail

getMediaTypesForProblemDetailback to summary
protected List<MediaType> getMediaTypesForProblemDetail()

Overrides org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getMediaTypesForProblemDetail.

Doc from org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.getMediaTypesForProblemDetail.

Return the supported media type(s) for ProblemDetail. By default, an empty list, unless overridden in subclasses.

Annotations
@Override
setObjectMapperback to summary
public void setObjectMapper(ObjectMapper objectMapper)

Overrides org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.setObjectMapper.

Doc from org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.setObjectMapper.

Configure the main ObjectMapper to use for Object conversion. If not set, a default ObjectMapper instance is created.

Setting a custom-configured ObjectMapper is one way to take further control of the JSON serialization process. For example, an extended com.fasterxml.jackson.databind.ser.SerializerFactory can be configured that provides custom serializers for specific types. Another option for refining the serialization process is to use Jackson's provided annotations on the types to be serialized, in which case a custom-configured ObjectMapper is unnecessary. The ObjectMapper parameter must be a XmlMapper instance.

Annotations
@Override