I have a JSP file with links like below:
<a href="links.do?method=homeAdmin">
<a href="links.do?method=signUp">
And I have an action class LinkAction.java
:
public class LinkAction extends org.apache.struts.action.Action {
public ActionForward signUp(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("signUp");
}
public ActionForward homeAdmin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("homeAdmin");
}
}
The problem is that it doesn't work. But when I change it to something like this, it works only for the signUp
action.
public class LinkAction extends org.apache.struts.action.Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("signUp");
}
}
I also tried changing it to
public class LinkAction extends DispatchAction { ... }
Here is my struts-config.xml
<action input="/index.jsp"
name="signUp"
path="/links"
scope="session"
type="Actions.LinkAction">
<forward name="signUp" path="/signUp.jsp"/>
<forward name="homeAdmin" path="/homeAdmin.jsp"/>
</action>
I want to use this single action file for all the links in my web page. How do I do it?