首页 > PHP资讯 > HTML5培训技术 > [struts2]2.3.14json-plugin存在bug<java.lang.NoSuchFie

[struts2]2.3.14json-plugin存在bug<java.lang.NoSuchFie

HTML5培训技术

项目启动时 一直报异常,不影响运行但是看着老烦人了。

添加上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.(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的属性,

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

这个是默认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 includeProperties;    private List 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;

一下地址 是修改好的jar包, 后放到项目中便可以。

这是下载地址:http://download.csdn.net/detail/liweifengwf/6641041




HTML5培训技术

本文由欣才IT学院整理发布,未经许可,禁止转载。
支持31不支持0