I have a form in jsp. There are two submit buttons: \"Search\" and \"Add New\" button. I had set each button with their own method attribute.
Set
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
to
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
Another way is to define multiple mappings for the same Action, like
in JSP:
<s:submit value="Search" action="employeeSearchAction" />
<s:submit value="Add New" action="employeeAddNewAction"/>
in Struts.xml
<action name="employeeSearchAction" class="example.EmployeeAction" method="doSearch">
<result>/example/search.jsp</result>
</action>
<action name="employeeAddNewAction" class="example.EmployeeAction" method="doAddNew">
<result>/example/add.jsp</result>
</action>
A third way is to use Wildcard Mappings.
P.S: If you go for the second one, I'll suggest, as a best practice, to use one Action for every logical action you have to perform...
If you have common data loaded / managed by both your actions, "search" and "addNew", then you can define a employeeBaseAction, extended by both employeeSearchAction and employeeAddNewAction.
It's 2014 now, and DMI usage is unanimously discouraged (today more than ever), other than pretty useless, so I strongly suggest you to use solution n.2.