spring-framework / org.springframework.http.converter.xml / MappingJackson2XmlHttpMessageConverter

MappingJackson2XmlHttpMessageConverter

open class MappingJackson2XmlHttpMessageConverter : AbstractJackson2HttpMessageConverter

Implementation of org.springframework.http.converter.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.

Compatible with Jackson 2.9 and higher, as of Spring 5.0.

Author
Sebastien Deleuze

Since
4.1

Constructors

<init>

MappingJackson2XmlHttpMessageConverter()

Construct a new MappingJackson2XmlHttpMessageConverter using default configuration provided by Jackson2ObjectMapperBuilder.

MappingJackson2XmlHttpMessageConverter(objectMapper: ObjectMapper)

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

Inherited Properties

DEFAULT_CHARSET

static val DEFAULT_CHARSET: Charset

Functions

setObjectMapper

open fun setObjectMapper(objectMapper: ObjectMapper): Unit

{@inheritDoc} The ObjectMapper parameter must be a XmlMapper instance.

Inherited Functions

canRead

open fun canRead(clazz: Class<*>, mediaType: MediaType): Boolean
open fun canRead(type: Type, contextClass: Class<*>, mediaType: MediaType): Boolean

canWrite

open fun canWrite(clazz: Class<*>, mediaType: MediaType): Boolean

getObjectMapper

open fun getObjectMapper(): ObjectMapper

Return the underlying ObjectMapper for this view.

read

open fun read(type: Type, contextClass: Class<*>, inputMessage: HttpInputMessage): Any

setPrettyPrint

open fun setPrettyPrint(prettyPrint: Boolean): Unit

Whether to use the DefaultPrettyPrinter when writing JSON. This is a shortcut for setting up an ObjectMapper as follows:

 ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); converter.setObjectMapper(mapper);