首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

Struts2 JSON Plugin-属性继承支持

2012-11-04 
Struts2 JSON Plugin--属性继承支持前两天做了一个SSH零配置实例,里面引入了Json插件,但发现对于继承其它A

Struts2 JSON Plugin--属性继承支持

前两天做了一个SSH零配置实例,里面引入了Json插件,但发现对于继承其它Action的返回结果中没有父Action的属性。

今天看了一下JSONResult类的相关属性,从而明了解决方法。

?

JSONResult类中的属性和默认值:

public class JSONResult implements Result{    private String defaultEncoding;    private List includeProperties;    private List excludeProperties;    private String root;    private boolean wrapWithComments;    private boolean prefix;    private boolean enableSMD;    private boolean enableGZIP;    private boolean ignoreHierarchy; //设置这个为false解决不能继承的问题    private boolean ignoreInterfaces;    private boolean enumAsBean;    private boolean noCache;    private boolean excludeNullProperties;    private int statusCode;    private int errorCode;    private String callbackParameter;    private String contentType;    private String wrapPrefix;    private String wrapSuffix;    public JSONResult()    {        defaultEncoding = "ISO-8859-1";        enableSMD = false;        enableGZIP = false;        ignoreHierarchy = true;        ignoreInterfaces = true;        enumAsBean = false;        noCache = false;        excludeNullProperties = false;    }}

?

Struts配置result:

?

<global-results><result name="json" type="json"><param name="ignoreHierarchy">false</param></result></global-results>

?

OK,MARK!

热点排行