DispatchAction类一个Action中包含多个业务处理<测试通过>
前台页面:DispatchActionTest.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<html:html>
<body>
<html:link href="userBank.do?method=saveMoney"><存钱</html:link>
<html:link href="userBank.do?method=getMoney">取钱</html:link>
<html:link href="userBank.do?method=findBalance">查询余额</html:link>
</body>
</html:html>
后台DispatchAction:
package com.login.struts.Action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
public class BankAction extends DispatchAction
{
public ActionForward saveMoney(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception
{
return mapping.findForward("save");
}
public ActionForward getMoney(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("get");
}
public ActionForward findBalance(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward("find");
}
}