我正在尝试将 java 字符串对象存储在 javabean 中并尝试将其转换为 xml 格式。它已成功存储,但每当我尝试从 java bean 获取数据时。我以简单的字符串格式而不是 xml 格式接收数据。
请帮我。
我的javabean代码如下:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "name", propOrder = {"username", "password"})
public class newBean {
@XmlElement(name = "username", required = true)
protected String username;
@XmlElement(name = "password", required = true)
protected String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}