防止列表被 XML 元素包裹
示例代码:
@XmlRootElement(name="user")
public class User implements Serializable
{
private long userid;
private IPerson person;
}
产生以下输出:
<user>
<person>
<firstname />
<lastname />
</person>
</user>
我想阻止生成“person”元素,以便 person-fields 将直接包含在“user”元素中,如下所示:
<user>
<firstname />
<lastname />
</user>
Can JAXB/EclipseLink beconfigured产生这个输出?
Example code:
@XmlRootElement(name="user")
public class User implements Serializable
{
private long userid;
private IPerson person;
}
Produces this output:
<user>
<person>
<firstname />
<lastname />
</person>
</user>
I'd like to prevent the 'person'-element from being generated, so that the person-fields will be directly included in the 'user'-element, like this:
<user>
<firstname />
<lastname />
</user>
Can JAXB/EclipseLink be configured to produce this output?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 EclipseLink JAXB (MOXy) 的
@XmlPath
用于映射此用例的扩展:了解更多信息
You can use EclipseLink JAXB (MOXy)'s
@XmlPath
extension to map this use case:For More Information