JSF强制URL重写 [英] JSF force URL rewriting

查看:68
本文介绍了JSF强制URL重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JSF,并且希望避免在浏览器中共享2个选项卡的相同会话.我认为一种简单的方法是强制重写网址,而不是使用Cookie.

I use JSF and I want to avoid a same session sharing 2 tabs in my browser. I think an easy way is to force url rewriting instead of using cookies.

有人可以告诉我如何用JSF强制进行URL重写吗?

Can anyone tell me how I can force the url rewriting with JSF?

谢谢.

史蒂芬(Stéphane)

Stéphane

推荐答案

我想避免同一会话在浏览器中共享2个标签

对不起,但这没有任何意义.您不能从服务器端进行控制.所有浏览器在所有打开的标签/窗口中都使用相同的会话(通过Ctrl + Shift + N可以使用匿名的标签/窗口,例如Chrome Ingognito).这就是所有浏览器的工作方式,完全超出您的控制范围.

Sorry, but this makes no sense. This is not something which you can control from the server side on. All browsers use the same session in all opened tabs/windows (expect of anonymized tabs/windows like Chrome Ingognito via Ctrl+Shift+N). That's just how all browsers work and completely beyond your control.

如果您遇到问题,则绝对应该以不同于尝试在多个浏览器选项卡/窗口中禁用会话共享的方式来解决它(这根本是不可能的).听起来很像是您在会话作用域bean中错误地存储了请求或查看作用域数据.你不应该那样做.您应该将请求范围的数据存储在请求范围的Bean中,并将视图范围的数据存储在视图范围的Bean中.会话作用域仅应用于会话作用域的数据,例如登录的用户及其首选项(如语言设置).

If you're having a problem with it, then you should absolutely solve it differently than attempting to disable session sharing in multiple browser tabs/windows (which simply isn't possible). It sounds much like as if you're incorrectly storing request or view scoped data in a session scoped bean. You should not do that. You should store request scoped data in a request scoped bean and view scoped data in a view scoped bean. The session scope should only be used for session scoped data, such as the logged-in user and its preferences like language settings.

我认为视图范围实际上就是您要寻找的;只要您通过回发与完全相同的视图(阅读器:完全相同的浏览器窗口/选项卡)进行交互,它就存在,并且不会在其他浏览器窗口/选项卡中共享.

I think the view scope is actually what you're looking for; it lives as long as you're interacting with the very same view (read: the very same browser window/tab) by postbacks and it it not shared in other browser windows/tabs.

这篇关于JSF强制URL重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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