Struts的2.3 - 重定向VS redirectAction [英] Struts 2.3 - redirect vs redirectAction

查看:226
本文介绍了Struts的2.3 - 重定向VS redirectAction的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间的主要区别是什么重定向 redirectAction 在Struts2.3环境。

What is the main difference between redirect and redirectAction in Struts2.3 context.

我已经看到下面的重定向和URL redirectAction

I have seen below URLs for redirect and redirectAction.

我清楚以下几点:


  • 重定向是一样的sendRedirect()方法。创建新的请求,清除previous值栈和行动(操作实例,动作失误,现场的错误等)不再可用。

  • redirectAction ,控制跳转到不同的动作(在相同或其他包装)

  • redirectAction 推荐过重定向。

  • redirect is like sendRedirect() method. New request is created which clear the previous value stack and action (action instance, action errors, field errors, etc) no longer available.
  • In redirectAction, control jumps to the different action(in same or other package)
  • redirectAction is recommended over redirect.

但是,当我实现了上述两个例子中,我只需要改变我的的struts.xml

But when I implemented both above mentioned examples, I only had to change my struts.xml.


  • 在两者的动作不再可用,

  • 创建新的请求,

  • 生成的URL是一样的。

首先,我很困惑书面 redirectAction

这是因为它没有比ServletRedirectResult更好
  要求你带code。通过该处理的ActionMapper URL模式
  在您的struts.xml配置文件。这意味着你可以改变
  在任何时候你的URL模式和应用程序仍然可以工作。
  强烈建议,如果您重定向到另一个
  行动中,使用这样的结果,而不是标准的重定向结果。

This is better than the ServletRedirectResult because it does not require you to encode the URL patterns processed by the ActionMapper in to your struts.xml configuration files. This means you can change your URL patterns at any point and your application will still work. It is strongly recommended that if you are redirecting to another action, you use this result rather than the standard redirect result.

第二,我仍然不是很了解这些的区别明确两者。

Second, I am still not very much clear about the difference between these both.

推荐答案

的区别是显而易见的: redirectAction 只不过是另一种结果类型,它扩展重定向结果类型提供的属性 actionName 命名方法。用于构建URI这些属性用于替换的位置的属性重定向结果类型。

The difference is obvious: redirectAction is just another result type, which extends redirect result type providing the attributes actionName, namespace, and method. These attributes used to build the URI used to substitute for the location attribute of the redirect result type.

该声明是好的,更好地的ActionMapping 构建URL这是由 redirectAction 结果型实现的,而不是编码它手动。即使手动始终使用 UrlHelper ,而不是硬编码。在JSP中始终使用取值:网址标记。

The statement is ok, better build URL from ActionMapping which is implemented by the redirectAction result type instead of coding it manually. Even manually always use the UrlHelper instead of hardcoding. In the JSP always use the s:url tag.

这篇关于Struts的2.3 - 重定向VS redirectAction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆