此处版本是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.
<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)。