Java.lang.NoSuchMethodException:com.yxq.action.AdminAction.addGoods () "Reprint"

Source: Internet
Author: User

java.lang.NoSuchMethodException:com.yxq.action.AdminAction.addGoods ()  
In learning struts2 Sometimes this anomaly occurs, it is summarized as follows, easy to refer to:
First try to see if the other methods can be used, if this is the case, perhaps your action class did not inherit the structs inside the dispatchaction or other classes. And you notice the parameter list of the method, the type order is correct, is in the following order: actionmapping mapping,actionform form, httpservletrequest request, HttpServletResponse response

2. The action class method is defined as the private type. The method that is accessed in the action below is defined as a private type. The program throws the above exception when it accesses its methods.

3, in fact, java.lang.NoSuchMethodException the root cause of this anomaly has two:

(1), missing some jar files;

(2), some jar files are duplicated.

4, the use of STRUTS2 framework problems
In the page using jquery Ajax call action in the Vailduname method, error, said my method does not exist. But the reality is there. public string Vailduname (String loginName) throwsexception{}
The problem is that in this parameter, there is no parameter in the Struts2 (struts2 is the method to execute the action through the reflection mechanism, the STRUTS2 specification is that the action method is not required, the method with parameters and the method without parameters is two different methods , so there will be a situation that cannot be found )

Workaround:
Private String LoginName;
Public String Vailduname () throws exception{}
Getter and setter methods for LoginName
That's when you use Ajax calls.

5, Java.lang.NoSuchMethodException This exception refers to your action does not have this method, indicating that you have found the action but did not find the method, so there are 2 cases,

1th situation: You are not submitted to this action, check the configuration file, there is no same path
2nd situation: There is no such method in your action

Java.lang.NoSuchMethodException:com.yxq.action.AdminAction.addGoods () "Reprint"

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.