@XmlRootElement

  • @XmlRootElement
@XmlRootElement
public class Student {
	private String name;
	
	private String age;
	
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getAge() {
		return age;
	}
	public void setAge(String age) {
		this.age = age;
	}

}

结果:



    19
    tom

 

  • @XmlAttribute,不放在属性上,放在方法上,不然报错有相同属性,暂时不知道为什么
@XmlRootElement
public class Student {
	private String name;
	
	private String age;
	
	
	@XmlAttribute
	public String getName() {
		return name;
	}
	public void

你可能感兴趣的:(Xml,Xml)