0
我收到了HashSet的com.google.gwt.user.client.rpc.SerializationException異常。
最初我以爲HashSet of Long是不支持的。
但是https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation包含這兩個。
會出現什麼問題?
我在這裏張貼了服務方法:
public Set<Long> getNamesFromIDs(Set<Long> ids) {
return manager.getNamesFromIDs(ids);
}
這裏,經理是參照其從庫中包含的管理類。 我張貼經理方法太:
public Set<Long> getNamesFromIDs(Set<Long> styleIds) {
List<Long> listIDs = new ArrayList<Long>(styleIds);
Map<Long, Discount> personMap = personDAO.getStyleIdToDiscountMap(listIDs, 0);
return personMap.keySet();
}
詳細異常消息:
com.google.gwt.user.client.rpc.SerializationException: Type 'java.util.HashMap$KeySet'
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.: instance = [30002, 30001]
我不明白你的意思是「KeySet不被GWT支持」。你的意思是操作不被支持或者類型?但是GWT支持Set,如下所述:https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation#Package_java_util – sachinpkale
KeySet已實現,其內部爲HashSet。它不是可串行化的,並且不意味着通過RPC發送。 – SSR
嘗試將KeySet的值複製到ArrayList/Hashset以通過RPC發送它。 – SSR