我有一个简单的restful服务,它使用RestEasy将JAXB-anntotated bean转换为响应XML。 XML标记可以包含转义的特殊字符(例如–)。但RestEasy marshaller再一次逃脱了&符号,我得到了& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp;而不是–在结果XML中。
我应该如何避免不必要的&符号逃脱?
答案 0 :(得分:0)
我一直在寻找它,我无法找到微调RESTEasy在写出响应时逃脱字符的方式。我正在使用拦截器来阻止这种编码。
作为参考,它在编码UTF-8 XML时在堆栈中的setEscape()发生。
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[],
...