1
我想在javabean中存儲java字符串對象,並試圖將其轉換爲xml格式。它存儲成功,但每當我嘗試從java bean.i中獲取數據以簡單的字符串格式收到而不是xml格式。javabean到xmltype字符串
請幫幫我。
我的代碼是下面的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;
}
}
謝謝你的幫助。它的工作。 –