JSF:NUMBER_OF_VIEWS_IN_SESSION 和后退按钮

发布于 2024-12-05 20:18:02 字数 428 浏览 0 评论 0原文

由于 AJAX4JSF 高内存消耗,我的应用程序出现内存问题。因此,我们决定将 NUMBER_OF_VIEWS_IN_SESSION 设置为 1,并牺牲后退按钮功能。

但是,将以下内容添加到 web.xml 文件后,后退按钮仍然有效。

<context-param>
  <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
  <param-value>1</param-value>
</context-param>

我想了解:后退按钮如何仍然有效?!!我读到,将 NUMBER_OF_VIEWS_IN_SESSION 设置为 1 会失去浏览器后退按钮功能。

预先感谢您的帮助。

I've got a memory problem in my application because of AJAX4JSF high memory consumption. So we have decided to set the NUMBER_OF_VIEWS_IN_SESSION to 1 and compromise the back button functionality.

However, after adding the following to the web.xml file, the back button still works.

<context-param>
  <param-name>org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION</param-name>
  <param-value>1</param-value>
</context-param>

I would like to understand: How the back button still works?!! I've read that setting the NUMBER_OF_VIEWS_IN_SESSION to 1 looses the browser back button functionality.

Thanks in advance for your help.

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

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

发布评论

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

评论(1

喜你已久 2024-12-12 20:18:02

我了解到,将 NUMBER_OF_VIEWS_IN_SESSION 设置为 1 会失去浏览器后退按钮功能。

您正在阅读的那篇文章要么是胡言乱语,要么您误解了该文章。后退按钮的功能决不能从服务器端进行控制。

也许这篇文章意味着您无法再提交通过后退按钮从浏览器缓存提供的页面,因为这会导致 ViewExpiredException。您需要创建一个Filter,它添加响应标头来指示浏览器不要缓存页面,这样按后退按钮就会在页面上触发全新的 GET 请求,这样您就不会在该页面上提交表单时,不再出现 ViewExpiredException

至于内存消耗高,我怀疑你的问题是由其他原因引起的。也许您只是在视图或会话作用域 bean 中拼凑了太多数据。彻底阅读此内容:为什么 JSF 在服务器上保存 UI 组件的状态? 最后但并非最不重要的一点是,在做出假设之前运行探查器。

I've read that setting the NUMBER_OF_VIEWS_IN_SESSION to 1 loses the browser back button functionality.

Either that article you're reading is babbling nonsense or you've misinterpreted the article. The back button's functionality can in no way be controlled from the server side on.

Perhaps the article meant the fact that you cannot submit the page which is been served from the browser cache by back button anymore because this would result in a ViewExpiredException. You'd need to create a Filter which adds response header to instruct the browser to not cache the page so that pressing the back button would fire a brand new GET request on the page so that you won't get a ViewExpiredException anymore when submitting a form on that page.

As to the high memory consumption, I suspect that your problem is caused by something else. Perhaps you're just cobbling too many data in a view or session scoped bean. Read this thoroughly: Why JSF saves the state of UI components on server? Last, but not least, run a profiler before making assumptions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文