如何在使用Jersey,jaxb和jax-rs时设置xml命名空间
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:
@XmlSchema(namespace = "http://www.example.org",
elementFormDefault = XmlNsForm.QUALIFIED)
package org.example;
import javax.xml.bind.annotation.XmlSchema;
import javax.xml.bind.annotation.XmlNsForm;
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:
@XmlType(namespace="http://www.example.org/foo")
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:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.