【发布时间】:2025-12-08 20:00:01
【问题描述】:
我正在学习 GWT。
我收到一个关于 serilizablity 的错误。
简要描述我的问题
在自定义属性类中
package com.exp.shared;
import java.io.Serializable;
import java.util.List;
public class Customproperties implements Serializable {
private Object value;
private List<?> values;
// more variable
public Customproperties() {
// TODO Auto-generated constructor stub
}
public Customproperties(String propertyName, List<?> object,
String propertyType, boolean mulitiValued, String cardinality, Boolean required) {
this.propertyName=propertyName;
this.values=object;
// more initialization
}
public Customproperties(String propertyName, List<?> object, String propertyType,
boolean multiValued) {
this.propertyName=propertyName;
this.values=object;
// more initialization
}
public Object getValue() {
return value;
}
public List<?> getValues() {
return values;
}
}
在 classImpl 之一的服务器包中,我正在使用 Customproperties 的对象
if (doc.getPropertyValue("cmis:objectTypeId").toString().equals("cmis:document")) {
customproperty=new Customproperties(p.getDefinition().getDisplayName(), p.getValue(), p.getType().toString(),p.isMultiValued());
}
else {
customproperty=new Customproperties(p.getDefinition().getDisplayName(), p.getValues(), p.getType().toString(),p.isMultiValued(),value.getCardinality(),value.isRequired());
}
如果条件 p.getValue() 返回 Object。 并且在其他条件下 p.getValues() 返回列表。
在CustomProperties class 中,当我将object variable 更改为string 时,它工作得非常好。
但我不改变它给我错误。
com.exp.shared.Customproperties' 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 = com.exp.shared.Customproperties@1aa5344
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:619)
我不想改变它 String 。我只想接收对象。因为这个对象有时可能是String、date、int。
请帮忙。
【问题讨论】:
标签: java gwt serialization gwt-rpc gwt2