DispachAction的编写流程:
1 编写处理类时,继承DispachAction,不覆盖execute方法,提供多个自定义的处理方法
。方法签名必须和execute一样
public ActionForward findAll(ActionMapping mapping, ActionForm form,
HttpServletRequest req, HttpServletResponse resp) throws Exception {
IPersonMgmtDAO dao = new PersonMgmtDAOImpl();
List<Person> persons = dao.findAllPersons();
req.getSession().setAttribute("persons", persons);
return mapping.findForward("showAllPersonsPage");
}
2 页面中需要传递一个额外的参数,参数名自定义,如methodName
如:<input type="hidden" name="method" value="dropInfo"/>
3 在struts-config.xml中配置额外表示方法名的参数
<action .... parameter="methodName">