Struts2的动态调用action方法
2014-10-26 23:12
429 查看
动态调用action方法,是指用 action!method 格式的请求来请求后台的逻辑处理
前提条件:在struts.xml或者struts.properties中配置
struts.enable.DynamicMethodInvocation常量为true
,否则动态调用不可用
查看源码:
在org.apache.struts2.dispatcher.mapper.DefaultActionMapper中
注意:通配符格式的action请求与参数struts.enable.DynamicMethodInvocation的值无关
前提条件:在struts.xml或者struts.properties中配置
struts.enable.DynamicMethodInvocation常量为true
,否则动态调用不可用
查看源码:
在org.apache.struts2.dispatcher.mapper.DefaultActionMapper中
protected ActionMapping parseActionName(ActionMapping mapping) { if(mapping.getName() == null) return null; //该参数即struts.enable.DynamicMethodInvocation常量的值, //因此设为true,才可以用动态调用请求action if(allowDynamicMethodCalls) { String name = mapping.getName(); int exclamation = name.lastIndexOf("!"); if(exclamation != -1) { mapping.setName(name.substring(0, exclamation)); mapping.setMethod(name.substring(exclamation + 1)); } } return mapping; }
注意:通配符格式的action请求与参数struts.enable.DynamicMethodInvocation的值无关
相关文章推荐
- Struts2基础之四:动态方法调用(DMI)和action通配符
- struts2动态方法调用 ActionName!methodName.action
- Struts2中DMI(动态方法调用)的错误问题(There is no Action mapped for namespace [/xxx] and action name [xxx!yyy] a)
- Struts2-02Action动态方法调用
- struts2拦截器的方法过滤功能在Action动态方法调用中的应用 .
- struts2教程:10、动态方法调用和使用通配符定义action
- Struts2动态方法调用,找不到Action
- Struts2关于Action的系统训练4关于动态方法调用DMI
- 【Struts2学习笔记(6)】Action动态方法调用
- struts2_7_Action类中方法的动态调用
- struts2学习 - action -3 动态方法调用 DMI
- 复习Struts2之Action动态方法调用
- struts2动态方法调用 ActionName!methodName.action
- struts2 Action专题之二:动态方法的调用
- struts2动态方法调用和使用通配符定义action
- struts2:动态方法调用与通配符定义action
- struts2中多个逻辑action(方法)的动态调用
- struts2配置及ActionMethod_DMI_动态方法调用
- struts2 动态调用action中方法
- Struts2 ActionMethod DMI(动态方法调用)