我正在用汽車的集合資源創建休息服務, 在代碼中,我設置集合的ID供以後使用, 但是,當我返回CarResources的響應該ID缺失。 另外,IDE似乎不是 '看' 這個屬性擴展ArrayList導致澤西島,Java中缺少的屬性
代碼不:
public class CarResources extends ArrayList<CarResource> {
private String id;
public void setId(String id) {
this.id = id;
}
public String getId() {
return id;
}
public CarResources (String id) {
this.id = id;
}
響應:
[
//Missing in the response is an id property of the entire List
{
"CarResource": {
"id": "TOYOTA_CAMERI",
"name": "Toyota",
"carType": "GAS"
}
},
{
"CarResource": {
"id": "HONDA_TYPE_R",
"name": "HONDA",
"carType": "GAS"
}
}
]
不擴展ArrayList。創建一個具有List作爲字段的自定義類 –