struts 1.x 和通配符的使用 MappingDispatchAction
环境多文件配置<?xml version="1.0" encoding="UTF-8"?>
?MappingDispatchAction配置文件
org.apache.struts.actions?
Class MappingDispatchActionjava.lang.Objectorg.apache.struts.action.Action
org.apache.struts.actions.BaseAction
org.apache.struts.actions.DispatchAction
org.apache.struts.actions.MappingDispatchAction
public class MappingDispatchActionextends DispatchAction?
An abstract?Action?that dispatches to a public method that is named by the?
parameter
?attribute of the corresponding ActionMapping. This is useful for developers who prefer to combine many related actions into a single Action class.To configure the use of this action in your?
struts-config.xml
?file, create an entry like this:<action path="/saveSubscription" type="org.example.SubscriptionAction" name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="method"/>
where 'method' is the name of a method in your subclass of MappingDispatchAction that has the same signature (other than method name) of the standard Action.execute method. For example, you might combine the methods for managing a subscription into a single MappingDispatchAction class using the following methods:
?
例子通配符的使用
?Action 对像
package com.test.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.MappingDispatchAction;public class TestAction extends MappingDispatchAction {//additionTestpublic ActionForward addTestAction(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response){request.setAttribute("usb", "Struts 1.x Addition Successful...");return mapping.findForward("add");}//additionTestpublic ActionForward deleteTestAction(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response){request.setAttribute("usb", "Struts 1.x Delete Successful...");return mapping.findForward("add");}//additionTestpublic ActionForward listTestAction(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response){request.setAttribute("usb", "Struts 1.x List Successful...");return mapping.findForward("add");}}??