日期:2014-05-16 浏览次数:20556 次
前两天做了一个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!