0
我的項目中存在一個特殊問題。我從基於Jersey + Grizzly2 + Moxy的mvn原型引導了一個REST端點。 此端點返回DataSource中所有POJO的Set。那麼,什麼情況是,當我@GET端點返回這樣的:在數據源將POJO設置爲JSON只返回「ID」字段
[{"id":1},{"id":0}]
2的對象。如果我調用println這些對象,我得到:
[[1 username1 fullName1 ROLE_USR], [0 username2 fullName2 ROLE_USR]]
這裏有什麼交易?爲什麼不是序列化所有字段,而只顯示id字段?
編輯1: 添加我的POJO定義是:通過切換回傑克遜
public class User {
private int id;
private final String emailAddress;
private final String username;
private String password;
private String displayName;
private String description;
private USER_ROLE role;
// Constructors, setters & getters
@Override
public String toString() {
return "[" + id + " " +
username + " " +
displayName + " " +
role + "]";
}
}
請分享pojo類也 –
添加到原來的問題..現在我想起它 - 也許這是因爲字段是私人的?情況會是這樣嗎?但是,如果我也是私人的,它怎麼能把'id'拉出來呢? – Alex