开发者

Conceptual question regarding application scope

I'm rather new to Spring and I was just wondering if someone would be able to clear some开发者_如何学Pythonthing up for me. What I am wondering is what is the scope of a spring mvc web application. Do users get a new instance of the application whenever they use it or is it like a singleton where everyone gets the same instance of the application?

For example, if I am storing some data in a controller that user 1 had accessed, and user 2 comes along and starts using the web application will user 2 see user 1's data or are they entirely separate instances?

I have tried to find an answer to this but with no luck. I have read about the different bean states within an application but haven't found anything about the application itself.

Any insight is greatly appreciated, HarleyQ14


The Spring MVC application is a singleton. Every user accesses the same application. To do otherwise would be cripplingly bad for performance and scalability.

When you say "I am storing some data in a controller", do you mean storing request- or session-related data in field of the controller object? If so, then the default behaviour of Spring will cause problems for you, since everything is shared.

If you want to have such request- or session-private controller instances, then consider using scoped beans.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜