Disable anpersand escaping in RestEasy XML response
I have a simple restful service that开发者_StackOverflow社区 transforms a JAXB-anntotated beans to response XML using RestEasy. The XML tags could contain escaped special characters (e.g. –). But RestEasy marshaller escapes ampersand symbols one more time and i get – instead of – in the result XML.
How should I avoid the unnecessary ampersand escaping?
I've been hunting this down and there's no way I can find to fine-tune the way RESTEasy escapes characters when it's writing out the response. I'm working on using an interceptor to prevent this encoding.
For reference, it happens at setEscape() in the stack when it encodes UTF-8 XML.
Encoded.setEscape(String, boolean) line: 107
UTF8XmlOutput.doText(String, boolean) line: 315
UTF8XmlOutput.text(String, boolean) line: 299
XMLSerializer.leafElement(Name, String, String) line: 325
RuntimeBuiltinLeafInfoImpl$1.writeLeafElement(XMLSerializer, Name, String, String) line: 210
RuntimeBuiltinLeafInfoImpl$1.writeLeafElement(XMLSerializer, Name, Object, String) line: 209
TransducedAccessor$CompositeTransducedAccessorImpl<BeanT,ValueT>.writeLeafElement(XMLSerializer, Name, BeanT, String) line: 250
SingleElementLeafProperty<BeanT>.serializeBody(BeanT, XMLSerializer, Object) line: 98
ClassBeanInfoImpl<BeanT>.serializeBody(BeanT, XMLSerializer) line: 332
XMLSerializer.childAsXsiType(Object, String, JaxBeanInfo, boolean) line: 699
SingleElementNodeProperty<BeanT,ValueT>.serializeBody(BeanT, XMLSerializer, Object) line: 152
ClassBeanInfoImpl<BeanT>.serializeBody(BeanT, XMLSerializer) line: 332
XMLSerializer.childAsSoleContent(Object, String) line: 593
ClassBeanInfoImpl<BeanT>.serializeRoot(BeanT, XMLSerializer) line: 320
XMLSerializer.childAsRoot(Object) line: 494
MarshallerImpl.write(Object, XmlOutput, Runnable) line: 315
MarshallerImpl.marshal(Object, Result) line: 244
MarshallerImpl(AbstractMarshallerImpl).marshal(Object, OutputStream) line: 75
JAXBXmlRootElementProvider(AbstractJAXBProvider<T>).writeTo(T, Class<?>, Type, Annotation[],
...
精彩评论