redirectaction配置总是报错

此处版本是2.3.4.struts2自带的文档里面有。

做的是上传文件后跳转到下载列表一个功能。

struts-2.3.4/docs/WW/redirect-action-result.html

rediectAction类型有有四个参数

  • actionName (default) - The name of the action that will be redirected to.

  • namespace - Used to determine which namespace the action is in that we're redirecting to. If namespace is null, the default will be the current namespace.

  • suppressEmptyParameters - Optional boolean (defaults to false) that can prevent parameters with no values from being included in the redirect URL.

  • parse - Boolean, true by default. If set to false, the actionName param will not be parsed for Ognl expressions.

  • anchor - Optional. Also known as "fragment" or colloquially as "hash". You can specify an anchor for a result.
配置的时候若是直接写action名字会提示错误。

<result name="success" type="redirectAction">
downloadList
</result>

但是即使提示有错,我在运行的时候却可以正常的运行(这个两个action是在同一个包中。不同包中的结果未测试)。

只能写入参数里面才会没哟提示错误。而且,就算是两个action在同一包中,依然还要加namespace这个属性(个人觉得这样有多余,默认的值应该就是相同的package,但是myeclipse偏偏就提示有错误)。

<result name="success" type="redirectAction">
<param name="namespace">/admin</param>
<param name="actionName">downloadList</param>
</result>

至此,便没有错误提示。

redirectAction跟chain的区别类似redirect跟forward。带了re就会重新请求一个,没带的,就会接着当前的请求继续请求(之前的action中的参数也跟着一起传给了下一个action)。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值