Detailed Explanation of the Scope of Spring and Bean in JSP

  • 2021-12-21 04:39:07
  • OfStack

Detailed Explanation of the Scope of Spring and Bean in JSP

The Bean element has an scope attribute that defines the scope of Bean and has the following five values:

1 > singleton:

Singleton schema, in the entire spring IOC container, Bean of singleton schema scope will generate only one instance. 1 The scope of Bean is singleton by default for the general Spring container

2 > prototype:

In contrast to singleton, a new Bean instance is generated each time the Bean in this scope is obtained through the container's getBean () method

3 > request:

For the same Http request, Bean under request scope will generate only one instance. This scope is only valid when using the Spring container in an Web application

4 > session:

For the same Http session, Bean under the scope of session will generate only one instance. This scope is also valid only when the Spring container is used in Web applications

5 > global session:

Each global Http Session corresponds to one Bean instance.

Thank you for reading, hope to help everyone, thank you for your support to this site!


Related articles: