重定向到Struts 2的操作 [英] ActionRedirect migration to Struts 2

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

问题描述

我目前正在将wepapp从Struts迁移到Struts 2,但遇到了一些困难.

I'm currently migrating a wepapp from Struts to Struts 2 and I'm experiencing some difficulties.

我有一些ActionRedirect,没有为其提供任何额外的参数,我也不知道如何迁移它,也许只是返回一个字符串是有效的?

I have some ActionRedirect with no extra parameters given to it and I don't know how to migrate it, maybe just return a string is efficient?

例如,我有这个:

return new ActionRedirect(mapping.getFindforward("failed");

这样做有效率吗?

return "failed";

当我有参数时,如何迁移它?我从两天开始从事这一工作.

And when I have parameters how can i migrate it ? I'm working on that part since 2 days.

推荐答案

在Struts2中,如果要创建类型为"redirect"的结果,则要进行重定向,如果要重定向到特定的URL, 或"redirectAction"(如果要重定向到配置中的已知操作).

In Struts2 redirects are made if you create the result of type "redirect" if you want to redirect to a specific URL, or "redirectAction" if you want to redirect to the known action in the configuration.

这些结果可以在Struts1中根据实际情况或全局配置进行配置.

These results you may configure on action or globally like forwards in the Struts1.

区别在于您不需要在mapping中找到它,它将由框架完成.

The difference is that you don't need to find it in the mapping it will be done by the framework.

如果返回"failed",则框架将查找名为"failed"的结果的配置,如果未能找到该结果,则将引发异常.

If you return "failed" the framework will look up the configuration for the result named "failed" and if it fails finding such result it will throw an exception.

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

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