struts2中使用DMI(动态调用方法)方式配置action

DMI方式配置xml有两种形式: web

1.使用 "!"方式,即 action名称 ! 方法名称 app

<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. 使用通配符方式 *,(有人建议用这种方式) jsp

<action name="*_*" class="edu.ncut.labshare.action.{1}Action"
			method="{2}">
			<result>/resource/{1}_{2}Success.jsp</result>
</action>

须要注意的是, url

1. 若是在web.xml 是这样配置的 spa

<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 code

而不要写成:http://localhost:8080/ALEConsole/aggression.action_update,由于.action是后缀。 xml

2. 新版的Struts2(具体从哪一个版本起忘了),默认关闭DMI功能。须要在struts.xml 中打开: io

<constant name="struts.enable.DynamicMethodInvocation" value="true"/> class


有一个问题就是:使用DMI方式配置,若是出现action之间的跳转的该怎么写,还请各位指点!
struts2

相关文章
相关标签/搜索