本文介绍了Spring bean范围:session和globalSession的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring框架中session和globalSession有什么区别?

What is the difference between session and globalSession in Spring framework?

<bean id="exampleBean" class="com.test.baen.ExampleBean" scope="session"/>
<bean id="exampleBean" class="com.test.baen.ExampleBean" scope="globalSession"/>

根据我的研究,两者在Web感知Spring ApplicationContext的上下文中都是有效的。

As per my study, both are valid in the context of a web-aware Spring ApplicationContext.

现在,会话bean范围将保持到用户会话,但是globalSession bean范围在整个应用程序中是否可用?

Now, session bean scope will remain until the user session, but will globalSession bean scope be available throughout the whole application?

是应用程序范围吗?

我无法理解术语全局HTTP会话;它将在整个全局HTTP会话中可用吗?

I am unable to understand the term "global HTTP Session"; will it be available throughout the global HTTP Session?

推荐答案

globalSession 是连接到Portlet应用程序的东西。当您的应用程序在Portlet容器中工作时,它由一些portlet构建。每个portlet都有自己的会话,但是如果你想为应用程序中的所有portlet存储全局变量,那么你应该将它们存储在 globalSession 中。此范围与基于Servlet的应用程序中的 session 范围没有任何特殊效果。

globalSession is something which is connected to Portlet applications. When your application works in Portlet container it is built of some amount of portlets. Each portlet has its own session, but if your want to store variables global for all portlets in your application than you should store them in globalSession. This scope doesn't have any special effect different from session scope in Servlet based applications.

这篇关于Spring bean范围:session和globalSession的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 11:30