【发布时间】:2011-05-30 13:28:51
【问题描述】:
我有一个返回可序列化对象列表的方法,我对该方法进行了 RPC 调用,一切顺利,直到反序列化过程:我收到以下消息:“无法反序列化响应”
注意:这是我的 gwt-rpc 响应字符串:
/ / OK [0,2768,3,2,0,2764,3,2,0,2761,3,2,0,2754,3,2,0,2750 , 3,2,0,2610,3,2,0,2606,3,2,0,2603,3,2,0,2600,3,2,9,1 ["java.util.ArrayList/3821976829 "" myPackage.MyEntity/845101117 "," java.lang.Integer/3438268394 "], 0.7]
DTO
public class MyEntity implements Serializable,IsSerializable
{
private static final long serialVersionUID = -9032157988566853424L;
public MyEntity ()
{
super();
}
private Integer _entityId;
private String _name;
public Integer getEntityId()
{
return _entityId;
}
public void setEntityId(Integer entityId)
{
this._entityId = entityId;
}
public String getName()
{
return _name;
}
public void setName(String _name)
{
this._name = _name;
}
}
接口
@RemoteServiceRelativePath("ContributorService.rpc")
public interface ContributorService extends RemoteService
{
ArrayList<MyEntity> myMethod(Arg arg);
}
public interface ContributorServiceAsync
{
void myMethod(Arg arg, AsyncCallback<ArrayList<MyEntity>> callback);
}
服务器实现:
@SuppressWarnings("serial")
public class ContributorServiceImpl extends RemoteServiceServlet implements ContributorService
{
@Override
public ArrayList<MyEntity> myMethod(Arg arg)
{
ArrayList<MyEntity> myList = new ArrayList<MyEntity>();
MyEntity myEntity=new MyEntity();
//code...
myList .add(myEntity);
return myList;
}
}
感谢您的帮助
【问题讨论】:
-
我以前从未见过在一个类上实现 Serializable,IsSerializable,通常只需要一个就足够了。我使用 Serializable,它总是对我有用。
-
我只使用了可序列化但它不起作用。
-
我认为我的问题在于列表,因为当我编辑返回对象而不是列表的方法时,一切正常。
-
您使用的是哪个 GWT 版本? GWT code.google.com/p/google-web-toolkit/issues/detail?id=1985
标签: java gwt rpc gwt-rpc deserialization