xml和bean之间转化
//bean
@XmlRootElement(name = "register")br/>@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlType(propOrder = {"name","age" })
public class User {
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;
}
@Override
public String toString() {
return "User{" +
"name=‘" + name + ‘\‘‘ +
", age=‘" + age + ‘\‘‘ +
‘}‘;
}
String xmlString = swriter.getBuffer().toString();
System.out.println(xmlString);
}catch (Exception e){
e.printStackTrace();
}
}
原文地址:https://blog.51cto.com/mufeng219/2417214
时间: 2024-10-10 23:09:48