使用Jaxb属性设置XML的编码 [英] Set encoding of XML using Jaxb properties

查看:445
本文介绍了使用Jaxb属性设置XML的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Web服务客户端配置为使用 Moxy marshall / unmarshall 服务有效负载。我的服务客户端没有控制 Jaxb配置
那就是说,我已经配置了我的客户端,使用 Moxy 通过添加一个 jaxb.properties 条目如下::

I configured my web service client to use Moxy to marshall / unmarshall the service payloads. My service client does not have a control on the Jaxb configuration. That said, I have configured my client to use Moxy by adding a jaxb.properties file with the entry as follows::

javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

我有要求更改有效载荷的编码,以便它的::

I have a requirement to change the encoding of the payload so that its::

<?xml version="1.0" encoding="windows-1252"?>

可以通过添加条目到 jaxb.properties (因为我们通过代码注入这个值可能会很多,因为我们已经有了各种框架)。

Is this possible by adding an entry to jaxb.properties (as it would be a lot of work for me to inject this value via code, due to the various frameworks we have in place).

推荐答案

MOXy和所有JAXB实现的编码由 Marshaller 中设置的 JAXB_ENCODING 属性控制。 。

Encoding for MOXy and all JAXB implementations is controlled by the JAXB_ENCODING property set on the Marshaller.

  • http://blog.bdoughan.com/2011/08/jaxb-and-java-io-files-streams-readers.html

这篇关于使用Jaxb属性设置XML的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆