什么IsSerializable或不在GWT中? [英] what IsSerializable or not in GWT?
问题描述
我在我的GWT项目中有这个简单的对象。我无法通过电线发送它。在这样的类中放置构造函数是不可能的?
public class MceDto implements IsSerializable {
public MceDto(String uri,String tag){
this.uri = uri;
this.tag = tag;
}
public String uri;
公共字符串标签;
公开日期;
}
我检查了* .gwt.rpc策略,并且该对象不存在含义它不是可序列化的或什么的。
谢谢
您使用的是哪个版本的GWT?
$ b $ <
java.io.Serializable
标记界面? 请参阅此GWT常见问题解答获取更多信息。
< hr>
根据 GWT序列化文档:
$ b
如果满足以下所有条件,则用户定义的类是可序列化的:
- 可指定
IsSerializable
或Serializable
,因为它直接实现了其中一个接口,或者是源自一个超类
- 所有非
final
,非 -瞬态
实例字段本身都是可序列化的, li>
- 从GWT 1.5开始,它必须有一个默认(零参数)构造函数(带有任何访问修饰符)或根本就没有构造函数。
所以你必须为你的类提供一个无参数构造函数,以便由GWT序列化。
I have this simple object in my GWT project. I cannot send it over the wire. Is it impossible to put a constructor in such a class?
public class MceDto implements IsSerializable {
public MceDto(String uri, String tag) {
this.uri = uri;
this.tag = tag;
}
public String uri;
public String tag;
public Date created;
}
I checked the *.gwt.rpc policy and the object is not there meaning it is not serializable or something. How can I know beforehand if it is possible to serialize the object?
Thank you
What version of GWT are you using?
The IsSerializable
interface is a vestige of GWT pre-1.4. Have you tried using the Java-standard java.io.Serializable
marker interface?
See this GWT FAQ for more.
As per the GWT serialization docs:
A user-defined class is serializable if all of the following apply:
- It is assignable to
IsSerializable
orSerializable
, either because it directly implements one of these interfaces or because it derives from a superclass that does- All non-
final
, non-transient
instance fields are themselves serializable, and- As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.
So you must provide a no-arg constructor for your class to be serializable by GWT.
这篇关于什么IsSerializable或不在GWT中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!