在这种写法中继承的是
DispatchAction
,它包含Action。
通过这种方式使程序结构显得清晰。
例如:
public class DispatchTestAction extends DispatchAction {
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
TestForm thisForm =(TestForm) actionForm;
if(thisForm.getMethod()==null){
public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
TestForm thisForm =(TestForm) actionForm;
if(thisForm.getMethod()==null){
return null;
} else{
return dispatchMethod(actionMapping,actionForm,httpServletRequest,httpServletResponse,
} else{
return dispatchMethod(actionMapping,actionForm,httpServletRequest,httpServletResponse,
thisForm.getMethod() );
//通过接收方法名,进行分发到不同的处理中去
}
}
}
public ActionForward printMessage(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){
System.out.println("===this is the method named printMessage====");
return actionMapping.findForward("success");
}
public ActionForward
printAlert(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){
System.out.println("====this is the method named printAlert====");
return null;
}
}
System.out.println("====this is the method named printAlert====");
return null;
}
}