每个用户JSF一个会话 [英] JSF One Session Per User

查看:156
本文介绍了每个用户JSF一个会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我刚刚开始学习JSF,我想知道这个问题。
我有16个复选框。当我打开页面并且我的兄弟也打开它时,似乎我们有相同的会话。当我点击其中一个复选框时,我的兄弟浏览器也会检查它。
所选复选框保存在 private ArrayList< String>中。 selectedBoes = new ArrayList< String>();

我的ManagedBean ist SessionScoped。


I just started learning with JSF and I'm wondering about this issue. I have 16 Checkboxes. When I open the Page and my Brother is opening it too it seems like we have the same session. When I click one of the checkboxes it is checked on my brothers browser too. The selected checkboxes are saved in a private ArrayList<String> selectedBoes = new ArrayList<String>();
My ManagedBean ist SessionScoped.

为什么会发生这种情况,如何避免它?

Why is this happening and how to avoid it?

推荐答案


我的兄弟会话ID是 cdbbb126e96060ddb924b9d5e591 。我的 cd9a5c4180bd9dfef0ec8db2ac4d

My brothers session ID is cdbbb126e96060ddb924b9d5e591. Mine is cd9a5c4180bd9dfef0ec8db2ac4d

然后唯一可能的原因是你实际没有将它们存储在会话范围内。症状表明您要么将它们存储在应用程序范围中,要么将其声明为 static (因此问题中的代码不代表实际代码所有;你的评论中的代码表明,你使用不同的属性名称也少或多,显然你试图从头顶键入它,你不应该这样做,你应该复制真正的代码)。

Then the only possible cause is that you're actually not storing them in the session scope. The symptoms indicate that you're either storing them in the application scope, or even that you declared it static (and thus the code in the question does not represent the real code at all; the code in your comments indicate that also less or more, you used a different property name, apparently you attempted to type it from top of head, you should not do that, you should copypaste the real code).

请注意,当您使用CDI的 @Named 而不是JSF的时@ManagedBean ,然后默认为应用程序范围,除非使用 javax.enterprise.context 范围注释另行指定。因此,如果您正在使用JSF自己的 javax.faces.bean.SessionScoped 注释(CDI不支持它),那么它仍将在应用程序范围内。

Note that when you're using CDI's @Named instead of JSF's @ManagedBean, then it would default to the application scope, unless otherwise specified with a javax.enterprise.context scope annotation. So if you're using JSF's own javax.faces.bean.SessionScoped annotation, which is not supported by CDI, then it would still be in the application scope.

这篇关于每个用户JSF一个会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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