I have a method given below in struts 2 action class;
public String add(String boo){
//codes here
}
I want to call the add method.
And my struts.xml
<action name="Login" class="com.json.action.JsonAction" method="add">
<param name="boo">boo</param>
<result name="success">/success.jsp</result>
</action>
And it shows an error like
java.lang.NoSuchMethodException: com.json.action.JsonAction.add().
How can i call the add method?
Struts actions do not have parameters and return a String.
What you want to do is have a String boo in your action class with getter/setters. It will then be available in your method. And if you have the default interceptor stack (see http://struts.apache.org/2.2.3/docs/interceptors.html) it will automatically be populated with “boo” according to your struts.xml configuration.