Can I force JAXB not to convert " into ", for example, when marshalling to XML?

后端 未结 14 2011
情深已故
情深已故 2020-11-29 09:27

I have an Object that is being marshalled to XML using JAXB. One element contains a String that includes quotes (\"). The resulting XML has " where t

14条回答
  •  广开言路
    2020-11-29 09:58

    For some reason I have no time to find out, it worked for me when setting

    marshaller.setProperty(Marshaller.JAXB_ENCODING, "utf-8");
    

    As opposed to using "UTF-8" or "Unicode"

    I suggest you try them, and as @Javatar said, check them dumping to file using:

    marshaller.marshal(shipOrder, new File(""));
    

    and opening it with a a decent text editor like notepad++

提交回复
热议问题