<!-- 方案一:一个action对应一个方法; --> <action name="add" class="com.gxxy.struts.kp03_methodcall.MultiMethodCall" method="add"> <result>/views/kp02_action/action.jsp</result> </action> <action name="delete" class="com.gxxy.struts.kp03_methodcall.MultiMethodCall" method="delete"> <result>/views/kp02_action/action.jsp</result> </action> <action name="update" class="com.gxxy.struts.kp03_methodcall.MultiMethodCall" method="update"> <result>/views/kp02_action/action.jsp</result> </action> <action name="query" class="com.gxxy.struts.kp03_methodcall.MultiMethodCall" method="query"> <result>/views/kp02_action/action.jsp</result> </action> <!-- 方案二: 动态方法调用(DMI) DMI: Dynamic Method Invocation http://host:port/contextPath/namespace/actionName!methodName -->
注意:一般动态方法调用都默认为false,首先要设置为true
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<action name="call" class="com.gxxy.struts.kp03_methodcall.MultiMethodCall"> <result>/views/kp02_action/action.jsp</result> </action> <!-- 方案三: 通配符(Wildcard) 把当前请求过来的地址进行过滤, 凡是以call_为actionName的请求都通过, 把请求地址中*所代表的 所有字符串放在后面的属性的值中, 值使用{} --> <action name="call_*" class="com.gxxy.struts.kp03_methodcall.MultiMethodCall" method="{1}"> <result>/views/kp02_action/action.jsp</result> </action> <action name="test_*" class="com.gxxy.struts.kp03_methodcall.TestCall" method="{1}"> <result>/views/kp02_action/action.jsp</result> </action> <action name="*_*" class="com.gxxy.struts.kp03_methodcall.{1}Call" method="{2}"> <result>/views/kp02_action/action.jsp</result> </action> <!-- http://localhost/struts/method/Test_update -->