写个Action继承MappingDispatchAction:
public class DoNothingAction extends MappingDispatchAction {
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("ADD method was invoked.");
return mapping.findForward("index");
}
public ActionForward update(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
System.out.println("UPDATE method was invoked.");
return mapping.findForward("index");
}
}
struts-config.xml中配置:
<action path="/addSomeThing" type="com.yourcompany.struts.action.DoNothingAction"
parameter="add"
scope="request">
<forward name="index" path="/index.jsp"></forward>
</action>
<action path="/updateSomeThing" type="com.yourcompany.struts.action.DoNothingAction"
parameter="update"
scope="request">
<forward name="index" path="/index.jsp"></forward>
</action>
页面中这样用:
<a href="addSomeThing.do">Execute ADD method</a><br>
<a href="updateSomeThing.do">Execute UPDATE method</a>