我开发了几个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