我開發了幾個GWT Web應用程序。最新的一個是對另一個的一點修改。除了最新版本之外,它們都運行良好。例外是:GWT錯誤:響應無法反序列化
The response could not be deserialized
我在Hibernate和GWT之間使用Hibernate和數據傳輸對象。每個DTO實現java.io.Serializable接口。正如我之前所說的,在其他應用程序中運行良好。有人可以幫我解決這個錯誤嗎?我不知道原因是什麼。
我的休眠對象代碼是:
public List<AttributeDTO> getAttributes(){
String sql = "from Attribute where (select max(tDate) from Attribute)-tDate < '0 days 00:05'";
List<Attribute> attributes = new ArrayList<Attribute>(DatabaseManager.createQuery(sql));
List<AttributeDTO> attributeDTOs = new ArrayList<AttributeDTO>(attributes != null ? attributes.size() : 0);
if (attributes != null) {
for (Attribute attribute : attributes) {
String date = format.format(attribute.gettDate());
attributeDTOs.add(new AttributeDTO(attribute.getiAttrId(),attribute.getsName(),attribute.getsValue(),date,attribute.getiDeviceId(),attribute.getsUnits(),new ApplicationFieldDTO()));
}
}
return attributeDTOs;
}
而且AttributeDTO是:
public class AttributeDTO implements Serializable {
private static final long serialVersionUID = 1L;
private int iAttrId;
private String name;
private String value;
private String date;
private String units;
private int iDeviceId;
private ApplicationFieldDTO appField;
public AttributeDTO() {}
public AttributeDTO(int attrId, String name, String value, String date, int deviceId, String units, ApplicationFieldDTO appField) {
this.iAttrId = attrId;
this.name = name;
this.value = value;
this.date = date;
this.iDeviceId = deviceId;
this.units = units;
this.appField = appField;
}
}
從GWT是返回AttributeDTO的List呼叫的getAttributes()方法。
謝謝!而不是List
您應該發佈DTO的代碼,這會給您帶來麻煩 – 2012-04-11 05:58:37