struts2中使用DMI(动态调用方法)方式配置action
2013-12-20 00:00
776 查看
DMI方式配置xml有两种形式:
1.使用 "!"方式,即 action名称 ! 方法名称
2. 使用通配符方式 *,(有人建议用这种方式)
需要注意的是,
1. 如果在web.xml 是这样配置的
而不要写成:http://localhost:8080/ALEConsole/aggression[b].action_update[/b],因为.action是后缀。
2. 新版的Struts2(具体从哪个版本起忘了),默认关闭DMI功能。需要在struts.xml 中打开:
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
有一个问题就是:使用DMI方式配置,如果出现action之间的跳转的该怎么写,还请各位指点!
1.使用 "!"方式,即 action名称 ! 方法名称
<action name="aggression" class="aggressionEventStatusAction" > <result name="success" >/WEB-INF/jsp/aggression/aggressionReport_main.jsp</result> <result name="update" type="chain"> <param name="actionName">aggression</param> <param name="namespace">/</param> </result> </action>
2. 使用通配符方式 *,(有人建议用这种方式)
<action name="*_*" class="edu.ncut.labshare.action.{1}Action" method="{2}"> <result>/resource/{1}_{2}Success.jsp</result> </action>
需要注意的是,
1. 如果在web.xml 是这样配置的
<filter-mapping> <filter-name>struts2</filter-name> <url-pattern>*.action</url-pattern> </filter-mapping>在页面上写链接的时候要写成: http://localhost:8080/ALEConsole/aggression!update .action 或者是 http://localhost:8080/ALEConsole/aggression_update.action
而不要写成:http://localhost:8080/ALEConsole/aggression[b].action_update[/b],因为.action是后缀。
2. 新版的Struts2(具体从哪个版本起忘了),默认关闭DMI功能。需要在struts.xml 中打开:
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
有一个问题就是:使用DMI方式配置,如果出现action之间的跳转的该怎么写,还请各位指点!
相关文章推荐
- struts2中使用DMI(动态调用方法)方式配置action
- 使用Struts2动态方法调用时(DMI)出现There is no Action mapped for namespace [/user] and action name [user!add] 问题
- struts2配置及ActionMethod_DMI_动态方法调用
- Struts2学习---基本配置,action,动态方法调用,action接收参数
- struts2学习笔记--------动态方法调用和使用通配符定义action
- 关于Struts2使用Action的动态方法调用
- struts2 2.5动态方法调用(DMI) dynamic method invoke 出现不被允许的方法时 Method add for action dynamic is not allowed! - [unknown location]
- struts2-10动态方法调用和使用通配符定义action
- 第三章Struts2 Action中动态方法调用、通配符的使用
- 3.6.3: 配置Action---使用Action的动态方法调用
- Struts2 Action中动态方法调用、通配符的使用
- Struts2自定义Action,自定义方法,DMI(动态方法调用),路径问题
- 框架 day27 Struts2 入门(概述,基本xml配置,动态方法调用,Action类,ServletAPI访问,结果集)
- Struts2笔记2--动态方法调用和Action接收请求方式
- Struts2动态方法调用和使用通配符定义action
- 动态方法调用 在Struts2中动态方法调用有三种方式,动态方法调用就是为了解决一个Action对应多个请求的处理,以免Action太多 第一种方式:指定method属性 这种方式我们前面已经用到过
- Struts2之动态方法调用(优点:调用同一个action中的多个方法不需要在配置文件中写多个指向相同action类的的action节点只需要一个action节点就行)
- Struts2关于Action的系统训练4关于动态方法调用DMI
- struts2如何动态调用action的方法以及使用json插件范围json格式的javascript对象
- struts2中动态方法调用和使用通配符定义Action