My idea is to perform actions using Struts2 the below way using a single Action class and multiple methods in it:
View roles action: manage/roles.action?method%3Aview=View
Add role action: manage/roles.action?method%3Aadd=Add
The URLs are called through invoking submit buttons as shown below from test.jsp:
<s:form namespace="/manage/" action="roles" method="get" >
<s:submit method="view" value="View" />
<s:submit method="add" value="Add" />
<s:submit method="edit" value="Edit" />
<s:submit method="delete" value="Delete" />
</s:form>
In struts.xml, I configured:
<package name="portal" namespace="/manage/" extends="struts-default">
<action name="home">
<result>/WEB-INF/jsp/manage/roles/test.jsp</result>
</action>
<action name="roles" class="struts2.actions.RoleAction" method="view">
<result name="success">/WEB-INF/jsp/manage/roles/viewRoles.jsp</result>
</action>
<action name="roles" class="struts2.actions.RoleAction" method="add">
<result name="input">/WEB-INF/jsp/manage/roles/addRole.jsp</result>
<result name="success">/WEB-INF/jsp/manage/roles/viewRoles.jsp</result>
</action>
Unfortunately, when I'm pressing View button, it's showing the result JSP of "add" method. Why?