使用JAXB的XML标头标记

Sun*_*pta 19 java jaxb

现在我将这作为我的JAXB Marshaller的XML输出

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><create></create>
Run Code Online (Sandbox Code Playgroud)

但我希望我的根元素为:

<create xmlns="http://ws.abc.com" xmlns:doc="http://ws.abc.com">
Run Code Online (Sandbox Code Playgroud)

我是否需要使用解析器修改它,或者是否有任何可用的注释.

bdo*_*han 36

您可以在上面设置以下属性Marshaller以删除标题:

marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
Run Code Online (Sandbox Code Playgroud)

欲获得更多信息