使用 Jersey、jaxb 和 jaxb 时如何设置 xml 命名空间jax-rs
使用 Jersey、jaxb 和 jaxb 时如何设置 xml 命名空间jax-rs
How do I set the xml namespace when using Jersey, jaxb & jax-rs
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这一切都是使用 JAXB 注释完成的。以下几点涉及您的域模型。
架构级别
您可以使用 @XmlSchema 包级别注释指定架构级别命名空间信息:
上述注释利用 elementFormDefault 将所有元素的命名空间默认为“http://www.example.org"。
类型级别
您可以使用@XmlType注释在类型级别覆盖命名空间:
属性/字段级别
和/或者您可以在注释本身上指定命名空间信息:
示例
我有一篇博客文章通过示例演示了这些概念:
This is all done using JAXB annotations. The points below refer to your domain model.
Schema Level
You can specify schema level namespace information using the @XmlSchema package level annotation:
The above annotation leveraging elementFormDefault will default the namespace of all elements to "http://www.example.org".
Type Level
You can override namespaces at the type level using the @XmlType annotation:
Property/Field Level
And/or you can specify namespace information on the annotations themselves:
Example
I have a blog post that demonstrates these concepts with an example: