如何在支柱1中的URL重定向?

发布于 2025-02-10 10:12:46 字数 1039 浏览 3 评论 0原文

我们的应用程序(仍在使用Struts 1)需要将用户重定向到新的登录页面(外部托管)。在类似的应用程序(使用Strut 2)中,我们具有正常工作。下面,我将显示我们的实施。最终,我想在支柱1中找到同等的内容。由于这个旧的不支持的软件,我很难找到任何在线文档。我非常感谢这里的任何建议。

struts.xml

<action name = "Home2" 
         class = "com.eppt.action.MasterAccountListAction2" 
         method = "wlgnReDirect">
          <result name = "unknownerror" type = "tiles">masteraccountlist</result>  
         <result name="wlgn" type="redirect">${wlgntUrl}</result>
         <result name="success" type="redirect">${wlgntUrl}</result>
</action>

重定向config java文件:

 public String wlgnReDirect() {
    try {
         wlgntUrl = "https://wwwdev.idev.com/secure-login/en-us/?redirectUrl=http://www.yahoo.com";
        nextScreen = "wlgn";
    } catch (Exception e) {
        addGenericError(request);
        return "unknownerror";
    }
    return nextScreen;
}

如上所述,这是在Struts 2中使用的。

Our application (still using Struts 1) needs to redirect the user to a new login page (hosted externally). In a similar application (using Struts 2), we have this working properly. Below, I will show our implementation. Ultimately I want to find the equivalent in Struts 1. I am having trouble finding any online documentation because of this old unsupported software. I would greatly appreciate any advice here.

struts.xml:

<action name = "Home2" 
         class = "com.eppt.action.MasterAccountListAction2" 
         method = "wlgnReDirect">
          <result name = "unknownerror" type = "tiles">masteraccountlist</result>  
         <result name="wlgn" type="redirect">${wlgntUrl}</result>
         <result name="success" type="redirect">${wlgntUrl}</result>
</action>

redirect config Java file:

 public String wlgnReDirect() {
    try {
         wlgntUrl = "https://wwwdev.idev.com/secure-login/en-us/?redirectUrl=http://www.yahoo.com";
        nextScreen = "wlgn";
    } catch (Exception e) {
        addGenericError(request);
        return "unknownerror";
    }
    return nextScreen;
}

Like stated above, this works as intended in Struts 2. How can I achieve the same in Struts 1?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

知足的幸福 2025-02-17 10:12:46

在Struts 1中,如果您以编程方式创建新的ActionForward并将其从操作方法返回,则可以实现相同的结果。

public ActionForward wlgnReDirect(ActionMapping m, ActionForm f, HttpServletRequest req, HttpServletResponse res) throws Exception
{
    try {
         wlgntUrl = "https://wwwdev.idev.com/secure-login/en-us/?redirectUrl=http://www.yahoo.com";
        nextScreen = "wlgn";
    } catch (Exception e) {
        addGenericError(request);
        return m.findForward("unknownerror");
    }
    return new ActionForward(redirectUrl, true);
}

In Struts 1 the same result could be achieved if you create a new ActionForward programmatically and return it from the action method.

public ActionForward wlgnReDirect(ActionMapping m, ActionForm f, HttpServletRequest req, HttpServletResponse res) throws Exception
{
    try {
         wlgntUrl = "https://wwwdev.idev.com/secure-login/en-us/?redirectUrl=http://www.yahoo.com";
        nextScreen = "wlgn";
    } catch (Exception e) {
        addGenericError(request);
        return m.findForward("unknownerror");
    }
    return new ActionForward(redirectUrl, true);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文