Post-Redirect-Get后的后退按钮行为 [英] Back Button behaviour after Post-Redirect-Get

查看:250
本文介绍了Post-Redirect-Get后的后退按钮行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序通过响应标头禁用浏览器上的缓存,然后使用Post-Redirect-Get模式启用后退按钮以重新获取当前页面。

但是现在重新测试它使用Firefox 12和IE 8我没有看到我期待的结果(或者我之前在IE 6中看到过的结果)。

My application disables caching on the browser via responses headers and then uses the Post-Redirect-Get pattern to enable the back button to "re-Get" the current page.
However on retesting this now with Firefox 12 and IE 8 I'm not seeing the results I was expecting (or that I had seen before with IE 6).

选择后退按钮后,我可以看到浏览器正在尝试执行原始请求(Post),而不是重定向请求(Get)。当我查看Firebug网络选项卡上的请求时,我看到以下内容:

Upon selecting the back button I can see that the browser is attempting to perform the original request (the Post), not the redirected request (the Get). When I look at the requests on the network tab of Firebug I see the following:

看起来浏览器将Post和Get视为相同的请求,因此选择后退按钮是重新 - 提交帖子:

Looks like the browser is treating the Post and Get as the same request and hence selecting the back button is re-submitting the Post:

我使用的是JSF,但我认为这是一个浏览器问题。有谁知道为什么浏览器没有执行重定向页面的获取?

I am using JSF, but I think this is a browser issue. Does anyone know why the browser is not performing a get of the redirected page?

推荐答案

它工作正常。后退按钮重新执行之前的 当前请求,该请求已重定向到reviewInfo.xhtml。

It's working fine. The back button re-executes the request before "POST accountDetails.xhtml" which is not listed in your 1st screenshot, but is according the 2nd screenshot apparently (and logically) a "GET accountDetails.xhtml". You're apparently in the bean associated with that view or in some filter doing some checks and redirecting to "registrationWelcome.xhtml". The "POST accountDetails.xhtml" in the 1st screenshot is the current request which has been redirected to "reviewInfo.xhtml".

返回按钮不会重新执行重定向。这是你自己的代码。后退按钮也不会重新执行POST请求,这将在第二个屏幕截图中确认。

The back button does not re-execute the redirect. It's your own code which did it. The back button does also not re-execute the POST request, which is confirmed in the 2nd screenshot.

这篇关于Post-Redirect-Get后的后退按钮行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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