Error: Java. Lang. nosuchmethodexception: com ..... Action, java. Lang. Class. getmethod ()

Source: Internet
Author: User

Just getting started with struts2, when passing parameters to the action, the system prompts an error all morning:

Java. Lang. nosuchmethodexception: com... Action, java. Lang. Class. getmethod ()......

Solutions found on the Internet. It is found that actions in struts2 cannot contain parameters, and only get and set methods can be used.

Java. Lang. nosuchmethodexception Solution

 

1. Action class does not inherit sTrDIS in uctsPatchAction or other classes

Have you tried other methods? If this is the case, it may be that your action class does not inherit dispatchaction or other classes in structs. Also, pay attention to the parameter list of the method. The type order must be correct, in the following order:

ActionmapPingMapping, actionfoRmForm
, Httpservletrequest request, httpservletresponse response.

2. The action class method is defined as the private type.

The method accessed in the following action is defined as private. When the program accesses its method, the above exception is thrown.

3. jar package problems

Some jar files are missing or some jar files are duplicated.

4. Problems with struts2 framework
When jquery Ajax is used on the page to call the vailduname method in action, an error is returned, indicating that my method does not exist. But it actually exists. Public String vailduname (string loginname) throws exception {} the problem lies in this parameter. struts2 cannot contain parameters.
Solution:
Private string loginname;
Public String vailduname () throws exception {}
Getter andSetTER Method
In this way, you can use ajax to call

Struts2 uses a reflection mechanism to execute action. Currently, the struts2 standard does not require parameters for action methods. There are two different methods: parameter methods and parameter-free methods, therefore, it may not be found.

5. The jar version is incorrect.

It should be a problem with the 3.6jar package. It's okay to switch back to the 3.2 package.

6. check whether this action is submitted. Your action does not have this method.

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.