且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在JSF导航后,单击浏览器后退按钮会导致“文档过期".在浏览器中

更新时间:2022-04-07 02:28:45

如果您使用后退按钮,那么我会收到文档已过期"

如果先前的请求是同步POST请求(表单提交),则会发生这种情况.您不应该使用POST进行页面间导航.使用GET.

That will happen if the previous request was a synchronous POST request (a form submit). You're not supposed to use POST for page-to-page navigation. Use GET for it.

换句话说,用<h:link/button>替换表示纯页面到页面导航链接/按钮的<h:commandLink/Button>.并且,当您需要在提交表单后导航到新页面时,例如要在提交条目后显示列表,请使用POST-redirect-GET.

In other words, replace <h:commandLink/Button> representing pure page-to-page navigation links/buttons by <h:link/button>. And, when you need to navigate to a new page after a form submit, e.g. to display a list after submit of an entry, use POST-redirect-GET.

  • When should I use h:outputLink instead of h:commandLink?
  • How to navigate in JSF? How to make URL reflect current page (and not previous one)
  • Is JSF 2.0 View Scope back-button safe?
  • Avoid back button on JSF web application

不相关与具体问题:PhaseListener是处理HTTP响应标头的错误工具.使用普通的Filter.

Unrelated to the concrete problem: a PhaseListener is the wrong tool for the job of manipulating HTTP response headers. Use a normal Filter.