Essential difference between Servlet context and S

2019-08-06 02:29发布

I'm reading the spring framework documentation and now I'm at application scope concept. What the documentation says about that concept is this:

This is somewhat similar to a Spring singleton bean but differs in two important ways: It is a singleton per ServletContext, not per Spring ApplicationContext

To me, what's unclear is how can we imagine the relationship between Spring application context and Servlet context.

I'd assume that there two possible cases for the relationship between them:

I

enter image description here

II

enter image description here

So, how does the Spring application context relate with Servlet context? Is it case I or case II or neither of them?

1条回答
We Are One
2楼-- · 2019-08-06 03:04

It's neither of them.

ServletContext is the standard Java EE application scope. Each deployed webapp has one and only one servlet context.

Inside this webapp, you can have one (typically) or several Spring application contexts: one per Spring-MVC dispatcher servlet.

查看更多
登录 后发表回答