我是 java XML 绑定的新手。
这是我的课
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* @author Martin Burchard
*
*/
@XmlRootElement(name = "user")
public class User {
private String id;
private String nickname;
private String email;
private String password;
@XmlElement(name = "id")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@XmlElement(name = "nickname")
public String getNickName() {
return nickname;
}
public void setNickName(String nickname) {
this.nickname = nickname;
}
@XmlElement(name = "email")
public String getEMail() {
return email;
}
public void setEMail(String email) {
this.email = email;
}
@XmlElement(name = "password")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
在创建/注册用户期间,必须提供密码,但稍后在询问用户信息时,XML 不应包含密码元素。是否可以将元素定义为只写?