[struts2]2.3.14 json-plugin 存在bug

添加上json plugin之后启动就会报错

java.lang.NoSuchFieldException: DEFAULT_PARAM

    at java.lang.Class.getField(Class.java:1537)

    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addResultTypes(XmlConfigurationProvider.java:569)

    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.addPackage(XmlConfigurationProvider.java:521)

    at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadPackages(XmlConfigurationProvider.java:292)

    at org.apache.struts2.config.StrutsXmlConfigurationProvider.loadPackages(StrutsXmlConfigurationProvider.java:112)

    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:250)

    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)

    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)

    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:473)

    at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)

    at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)

    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)

    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)

    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)

    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4746)

    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5399)

    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

    at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3926)

    at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426)

    at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345)

    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)

    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)

    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)

    at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)

    at java.lang.Thread.run(Thread.java:722)

 

 

 这个错误是因为struts2在启动的时候默认检查result的属性,

一般我们写<result>/WEB-INF/index.jsp</result>

这个是默认result的names="success" DEFAULT_PARAM为"/WEB-INF/index.jsp"的意思.

默认的stuts2的result会有DEFAULT_PARAM属性比如StrutsResultSupport这个基类

public abstract class StrutsResultSupport implements Result, StrutsStatics {



    private static final Logger LOG = LoggerFactory.getLogger(StrutsResultSupport.class);



    /** The default parameter */

    public static final String DEFAULT_PARAM = "location";



    private boolean parse;

    private boolean encode;

    private String location;

    private String lastFinalLocation;

 

 然而jsonresult就没有这个属性

 

public class JSONResult implements Result {



    private static final long serialVersionUID = 8624350183189931165L;



    private static final Logger LOG = LoggerFactory.getLogger(JSONResult.class);



    private String encoding;

    private String defaultEncoding = "ISO-8859-1";

    private List<Pattern> includeProperties;

    private List<Pattern> excludeProperties;

    private String root;

    private boolean wrapWithComments;

    private boolean prefix;

    private boolean enableSMD = false;

    private boolean enableGZIP = false;

    private boolean ignoreHierarchy = true;

    private boolean ignoreInterfaces = true;

    private boolean enumAsBean = JSONWriter.ENUM_AS_BEAN_DEFAULT;

    private boolean noCache = false;

    private boolean excludeNullProperties = false;

    private int statusCode;

    private int errorCode;

    private String callbackParameter;

    private String contentType;

    private String wrapPrefix;

    private String wrapSuffix;

相关解决方案暂不公布.有兴趣可以找我要.

 

你可能感兴趣的:(exception)