What is the difference between ApplicationContext and WebApplicationContext in Spring MVC?

前端 未结 5 845
迷失自我
迷失自我 2020-11-22 06:53

What is the difference between Application Context and Web Application Context?

I am aware that WebApplicationContext is used for Spring MVC architectur

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 07:26

    Web application context, specified by the WebApplicationContext interface, is a Spring application context for a web applications. It has all the properties of a regular Spring application context, given that the WebApplicationContext interface extends the ApplicationContext interface, and add a method for retrieving the standard Servlet API ServletContext for the web application.

    In addition to the standard Spring bean scopes singleton and prototype, there are three additional scopes available in a web application context:

    • request - scopes a single bean definition to the lifecycle of a single HTTP request; that is, each HTTP request has its own instance of a bean created off the back of a single bean definition
    • session - scopes a single bean definition to the lifecycle of an HTTP Session
    • application - scopes a single bean definition to the lifecycle of a ServletContext

提交回复
热议问题