类 Jaxb2RootElementHttpMessageConverter
- java.lang.Object
- org.springframework.http.converter.AbstractHttpMessageConverter<T>
- org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
- org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter<Object>
- org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter
- 所有已实现的接口:
HttpMessageConverter<Object>
public class Jaxb2RootElementHttpMessageConverter extends AbstractJaxb2HttpMessageConverter<Object>
Implementation ofHttpMessageConverterthat can read and write XML using JAXB2.This converter can read classes annotated with
XmlRootElementandXmlType, and write classes annotated withXmlRootElement, or subclasses thereof.Note: When using Spring's Marshaller/Unmarshaller abstractions from
spring-oxm, you should use theMarshallingHttpMessageConverterinstead.- 从以下版本开始:
- 3.0
- 作者:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev
- 另请参阅:
MarshallingHttpMessageConverter
字段概要
从类继承的字段 org.springframework.http.converter.AbstractHttpMessageConverter
logger
构造器概要
构造器 构造器 说明 Jaxb2RootElementHttpMessageConverter()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 booleancanRead(Class<?> clazz, MediaType mediaType)This implementation checks if the given class is supported, and if the supported media typesinclude the given media type.booleancanWrite(Class<?> clazz, MediaType mediaType)booleanisProcessExternalEntities()Return whether XML external entities are allowed.booleanisSupportDtd()Return whether DTD parsing is supported.protected SourceprocessSource(Source source)protected ObjectreadFromSource(Class<?> clazz, HttpHeaders headers, Source source)Abstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).voidsetProcessExternalEntities(boolean processExternalEntities)Indicate whether external XML entities are processed when converting to a Source.voidsetSupportDtd(boolean supportDtd)Indicate whether DTD parsing should be supported.protected booleansupports(Class<?> clazz)Indicates whether the given class is supported by this converter.protected voidwriteToResult(Object o, HttpHeaders headers, Result result)Abstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).从类继承的方法 org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter
createMarshaller, createUnmarshaller, customizeMarshaller, customizeUnmarshaller, getJaxbContext
从类继承的方法 org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter
readInternal, transform, writeInternal
从类继承的方法 org.springframework.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write
构造器详细资料
Jaxb2RootElementHttpMessageConverter
public Jaxb2RootElementHttpMessageConverter()
方法详细资料
setSupportDtd
public void setSupportDtd(boolean supportDtd)
Indicate whether DTD parsing should be supported.Default is
falsemeaning that DTD is disabled.
isSupportDtd
public boolean isSupportDtd()
Return whether DTD parsing is supported.
setProcessExternalEntities
public void setProcessExternalEntities(boolean processExternalEntities)
Indicate whether external XML entities are processed when converting to a Source.Default is
false, meaning that external entities are not resolved.Note: setting this option to
truealso automatically setssetSupportDtd(boolean)totrue.
isProcessExternalEntities
public boolean isProcessExternalEntities()
Return whether XML external entities are allowed.
canRead
public boolean canRead(Class<?> clazz, MediaType mediaType)
从类复制的说明:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media typesinclude the given media type.- 指定者:
canRead在接口中HttpMessageConverter<Object>- 覆盖:
canRead在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the class to test for readabilitymediaType- the media type to read (can benullif not specified); typically the value of aContent-Typeheader.- 返回:
trueif readable;falseotherwise
canWrite
public boolean canWrite(Class<?> clazz, MediaType mediaType)
从类复制的说明:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- 指定者:
canWrite在接口中HttpMessageConverter<Object>- 覆盖:
canWrite在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the class to test for writabilitymediaType- the media type to write (can benullif not specified); typically the value of anAcceptheader.- 返回:
trueif writable;falseotherwise
supports
protected boolean supports(Class<?> clazz)
从类复制的说明:AbstractHttpMessageConverterIndicates whether the given class is supported by this converter.- 指定者:
supports在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the class to test for support- 返回:
trueif supported;falseotherwise
readFromSource
protected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws IOException
从类复制的说明:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).- 指定者:
readFromSource在类中AbstractXmlHttpMessageConverter<Object>- 参数:
clazz- the type of object to returnheaders- the HTTP input headerssource- the HTTP input body- 返回:
- the converted object
- 抛出:
IOException- in case of I/O errors
processSource
protected Source processSource(Source source)
writeToResult
protected void writeToResult(Object o, HttpHeaders headers, Result result) throws IOException
从类复制的说明:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).- 指定者:
writeToResult在类中AbstractXmlHttpMessageConverter<Object>- 参数:
o- the object to write to the output messageheaders- the HTTP output headersresult- the HTTP output body- 抛出:
IOException- in case of I/O errors