在 Internet Explorer 中重定向时保留 URL 片段

2024-04-24

我目前面临单页应用程序中 URL 片段的挑战。登录时,用户将通过 Struts 重定向到包含 URL 片段/哈希/锚点部分的 url。

<action name="LoginAction" class="de.my.stuff.LoginAction">
    <interceptor-ref name="myStack" />
    <result name="error">
         <param name="location">/jsp/login.jsp</param>
         <param name="anchor">${hash}</param>
    </result>
    <result name="success" type="redirectAction">
        <param name="actionName">LoginSuccessAction</param>
        <param name="anchor">${hash}</param>                                
    </result>
</action>

正如您所看到的,URL 片段是通过 struts 附加的anchor范围。我用 IE11、Chrome 和 Firefox 对此进行了测试。

Chrome 和 Firefox 将保留重定向 URL 中的信息。 IE11不会。因为我不能成为第一个面临这个问题的人,所以我的问题是:

IE10 和 IE11 有好的解决方法吗?我见过一些使用 cookie 的解决方案,但我们的应用程序必须能够在禁用 cookie 的情况下运行。

我读到 Eric Law 写的一篇博客,提到这个问题存在于 IE10 之前的版本中:

http://blogs.msdn.com/b/ieinternals/archive/2011/05/17/url-fragments-and-redirects-anchor-hash-missing.aspx http://blogs.msdn.com/b/ieinternals/archive/2011/05/17/url-fragments-and-redirects-anchor-hash-missing.aspx

他还指出 IE10 和 IE11 现在应该保留该片段,但我无法让它工作。我有什么遗漏的吗?

示例网址:

http://localhost:1234/myapp#id_123abgheji324


None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Internet Explorer 中重定向时保留 URL 片段 的相关文章

随机推荐