【发布时间】:2012-03-05 19:01:34
【问题描述】:
我有一个 JSF 2.0 应用程序(App#1),它有一个托管的 Session Scoped bean,它执行一些业务逻辑,如验证等。单击 Continue 按钮后,另一个纯 html 表单页面显示给用户并单击此页面上的提交按钮会将表单提交到不同的应用程序(App#2)。在 App#2 完成工作后,会向用户显示来自 App#3 的页面。请注意,所有这些都发生在相同的浏览器选项卡中。
在 App#3(它也是一个 JSF 2.0 应用程序)中,我想删除 App#1 的会话范围 bean。我怎么做?我尝试了以下选项,但它们似乎都不起作用。
//First approach
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("app1Bean");
上面的代码行我得到 null
//second approach
HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
.getExternalContext().getSession(true);
session.removeAttribute("app1Bean");
这里也为空。
【问题讨论】:
-
对不起,如果代码不清楚,我在代码中放了一个 Sysout 说 if(FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("app1Bean") == null ) { System.out.println("app1Bean is null");} 这个 Sysout 出现在控制台上
-
这些应用程序是否在服务器上配置为使用相同的会话?听起来不是,但也许对你来说不是很明显,只是想确定一下。
-
我几乎可以肯定没有设置此类设置(Websphere 7.0)。这是实现我想要的唯一方法吗?
标签: jsf-2 form-submit managed-bean session-scope