[Struts2] 2.3.14json-plugin bug & lt; java. lang. NoSuchFieldException: DEFAULT_PARAM & gt;

Source: Internet
Author: User
When the project is started, an exception is reported, which does not affect the running but is annoying. After jsonplugin is added and started, the error javalangNoSuchFieldException: DEFAULT_PARAMatjavalangClassgetField (Classjava: 1537) will be reported)

When the project is started, an exception is reported, which does not affect the running but is annoying.

After json plugin is added, an error is reported when it is started.

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)
 

This error occurs because struts2 checks the result attributes by default at startup,

Generally, we write /WEB-INF/index. jsp

This is the default result names = "success" DEFAULT_PARAM is "/WEB-INF/index. jsp" meaning.

The default stuts2 result will have the DEFAULT_PARAM attribute, such as the base class 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;
However, jsonresult does not have this attribute.

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;
  
 

The address below is the modified jar package, which can be downloaded and put into the project.

This is: http://download.csdn.net/detail/liweifengwf/6641041




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.