像这样的代码,//------------------------packagestep2;importjava.util.Set;importjavax.xml.bind.annotation.XmlElement;importjavax.xml.bind.annotation.XmlElementWrapper;impo...
像这样的代码,
//------------------------
package step2;
import java.util.Set;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@XmlRootElement
@XmlType(propOrder = { "id", "name", "age","book"})
public class Customer {
String name;
int age;
int id;
Set book;
@XmlElement(name="name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlElement(name="age")
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@XmlElement(name="id")
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@Override
public String toString() {
return "Customer [id=" + id + ",name=" + name + ",age=" + age + ",book=" + book + "]";
}
@XmlElementWrapper(name="books")
@XmlElement(name="book")
public Set getBook() {
return book;
}
public void setBook(Set book) {
this.book = book;
}
}
展开