在 RestEasy XML 响应中禁用 anpersand 转义

发布于 2024-12-02 11:44:16 字数 203 浏览 1 评论 0原文

我有一个简单的 Restful 服务,它使用 RestEasy 将 JAXB 注释的 bean 转换为响应 XML。 XML 标记可以包含转义的特殊字符(例如 –)。但是 RestEasy marshaller 再次转义 & 符号,我得到 –而不是 –在结果 XML 中。

我应该如何避免不必要的&符号转义?

I have a simple restful service that 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢好甜 2024-12-09 11:44:16

我一直在寻找这个问题,但我无法找到微调 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[], 
...

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[], 
...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文