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

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之间的跳转的该怎么写,还请各位指点!

转载于:https://my.oschina.net/3pgp/blog/756488

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值