2011-09-01 50 views
0

我有一個簡單的restful服務,它使用RestEasy將JAXB-anototated bean轉換爲響應XML。 XML標籤可能包含轉義的特殊字符(例如–)。但RestEasy編組人員又一次逃脫&符號,我得到了& amp;#8211;而不是–在結果XML中。在RestEasy XML響應中禁用連接符轉義

我應該如何避免不必要的&符號轉義?

+1

你指的是什麼標籤?他們如何定義?你應該給一個例子。 –

回答

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[], 
...