【发布时间】:2013-04-12 08:31:13
【问题描述】:
我可以通过以下方式将属性序列化到 Base Class (2 Levels)。
public class BaseRoot{
String prop1; //getter and setter
}
public class SubClass extends BaseRoot{
String prop2; //getter and setter
}
public class ActionClass extends SubClass{
String prop3; //getter and setter
}
在 struts json 中,我可以使用
序列化所有属性<result type="json">
<param name="ignoreHierarchy">false</param> //This will allow parent to be serializable
<param name="excludeProperties">price,description</param> //Exclude parameters
</result>
但我只想序列化类 ActionClass 和 SubClass。我不想序列化 BaseRoot 和其他由 BaseRoot 类扩展的类。我知道我可以排除属性。但我想从序列化中排除整个类。
【问题讨论】:
标签: java json inheritance serialization struts2