我正在使用 GWT-RPC 创建应用程序。在某些时候,服务器使用 Collections.unmodifiableList(List l) 返回一个 Collection 给客户端。客户端报错:
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.Collections$UnmodifiableList' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized
所以,我需要一种替代方法来获得唯一可读的集合,我该怎么做?非常感谢
我的代码如下:
try {
LinkedList all=new LinkedList();
while(res.next()){
all.add(objectFromCursor(res));
}
return Collections.unmodifiableList(all);
} catch (SQLException e) {
throw new ExceptionHandler("Error: "+e.getMessage());
}
private static Film objectFromCursor(ResultSet res) throws SQLException{
Film film=new Film(res.getString(1));
film.setRegista(res.getString(2));
film.setAnnoDiProduzione(res.getInt(3));
return film;
}