首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts 1.x 跟通配符的使用 MappingDispatchAction

2012-10-23 
struts 1.x 和通配符的使用MappingDispatchAction环境多文件配置?xml version1.0 encodingUTF-8??

struts 1.x 和通配符的使用 MappingDispatchAction

环境多文件配置<?xml version="1.0" encoding="UTF-8"?>

?MappingDispatchAction配置文件

org.apache.struts.actions?
Class MappingDispatchAction
java.lang.Object  struts 1.x 跟通配符的使用  MappingDispatchActionorg.apache.struts.action.Action      struts 1.x 跟通配符的使用  MappingDispatchActionorg.apache.struts.actions.BaseAction          struts 1.x 跟通配符的使用  MappingDispatchActionorg.apache.struts.actions.DispatchAction              struts 1.x 跟通配符的使用  MappingDispatchActionorg.apache.struts.actions.MappingDispatchAction

public class MappingDispatchAction
extends 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");}}
?

?

热点排行