在我的應用程序中,我使用庫球衣和Apache CXF來實現REST調用。特別是,我創建了我的DTO,一個服務和一個dao,通過put方法將一條記錄插入數據庫。客戶端澤西和RESTful把對象列表
下面的代碼工作,但我的問題是,當某些客戶端報告錯誤傳遞DTO的列表:
/* Client Rest */
WebResource service = clientJersey.get().resource(this.baseURI);
GaraDTO garaDTO = new GaraDTO();
garaDTO.setVersion("0");
..........................
ClientResponse response = service.path("rest").path("gare").accept(this.mediaType).put(ClientResponse.class, garaDTO);
/* DTO */
@XmlRootElement(name = "gara")
public class GaraDTO {
private Integer version;
. . . . . . . . . . . .
public GaraDTO(){
}
@XmlElement
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
. . . . . . . . . . . .
}
/* Service */
@Override
@PUT
@Consumes(MediaType.APPLICATION_XML)
public void putInsert(GaraDTO garaDto){
....................
//insert DB
....................
}
如果已經創建DTO的ArrayList後,步驟此列表客戶端出現錯誤。
List<GaraDTO> listGaraDTO = new ArrayList();
listGaraDTO.add(garaDTO1);
listGaraDTO.add(garaDTO2);
..............................
ClientResponse response = service.path("rest").path("gare").accept(this.mediaType).put(ClientResponse.class, listGaraDTO);
如何傳遞DTO列表?
感謝