DMI方式配置xml有两种形式:
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.action_update,因为.action是后缀。
2. 新版的Struts2(具体从哪个版本起忘了),默认关闭DMI功能。需要在struts.xml 中打开:
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
有一个问题就是:使用DMI方式配置,如果出现action之间的跳转的该怎么写,还请各位指点!