开发者

"session" bean scope in a web application - reliable?

开发者_StackOverflow社区

Can you rely on this scope and be sure that every time

1) a new session starts, the Spring bean will be initialized with default values

2) while session is kept alive, the current object will store its state during session life, will never be lost or corrupted and can always be got with [webappcontext].getBean ?


  1. Not quite - the Spring bean will be created the first time it is referenced within each new HTTP session. The creation of a new HTTP session will not trigger the immediate creation of every session-scoped Spring bean, that would kill performance. They are initialized lazily, on demand.
  2. Yes

Both are guaranteed. Do you have reason to think otherwise?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜