MappingDispatchAction and DispatchAction

The DispatchAction class (org.apache.struts.actions.DispatchAction) provides a way to group all related functions [/color] into a single action class. It’s a useful mechanism to avoid create separate action classe for each function.

Struts MappingDispatchAction class is used to group similar functionality[color=red]
into a single action class, and execute the function depends on parameter attribute of the corresponding ActionMapping.

------------------

LanguageSelectAction extends DispatchAction
                     ----   chinese( . . . . . .){..}
                     ----   english( . ..   ..  ) {..}
                     -----   fresh( . . . .  .)    {..}
<action  path="/Locale"                  type="com.mkyong.common.action.LanguageSelectAction"
name="userForm"
parameter="method"
  ........ >
<forward name="success" path="/pages/multi-language.jsp"/>
</action>
<html:link page="/Locale.do?method=france">France</html:link>


------------------分割线--------------------------
public class MyCustomDispatchAction extends MappingDispatchAction{
                                           ---public ActionForward generateXML(..){..}
                                           ---public ActionForward generateExcel(..){..}
-----------------------
<action-mappings>
<action path="/CustomDispatchActionXML"
type="com.mkyong.common.action.MyCustomDispatchAction"
parameter="generateXML" >
<forward name="success" path="/pages/DispatchExample.jsp"/>
</action>

<action path="/CustomDispatchActionExcel"
type="com.mkyong.common.action.MyCustomDispatchAction"
parameter="generateExcel" >
<forward name="success" path="/pages/DispatchExample.jsp"/>
</action>
</action-mappings>
---------------------
   <html:link action="/CustomDispatchActionXML" >
           Generate XML File
   </html:link>
   |
   <html:link action="/CustomDispatchActionExcel" >
           Generate Excel File
   </html:link>




注:摘自 http://www.mkyong.com/

你可能感兴趣的:(apache,xml,struts,Excel)