@Scope simple point is to specify the scope of the bean
The official explanation is that scope is used to declare that the object in the IOC container should be in a qualified scenario or that the object's survival space, that is, before the IOC container enters the appropriate scope, the objects are generated and assembled, and the container will usually destroy the objects after they are no longer qualified for those scopes.
The default is singleton mode, where only a shared bean instance exists in the Singleton:spring IOC container, and all requests to the bean, as long as the ID matches the bean definition, will return only the same instance of the bean, and one container corresponding to the bean.
Prototype for multiple cases: each request (injecting it into another bean, or invoking the container's Getbean () method programmatically) produces a new bean instance that is equivalent to the operation
request indicates that a new bean will be generated for each HTTP request, and that the bean is valid only within the current HTTP requests session The representation scope indicates that a new bean is generated for each HTTP request, and that the bean is valid only within the current HTTP session for the global session scope similar to the standard HTTP session scope, However, it only makes sense in portlet-based Web applications. The Portlet specification defines the concept of a global session, which is shared by all the various portlets that make up a portlet Web application. The bean defined in the global session scope is limited to the lifetime of the world Portlet session. If you use the global session scope to identify the bean in the Web, the Web will automatically be used as the session type to use in the request, session, global When using the session, the first thing to do is to configure the Web. XML in the initialization website If you are using a Web container of servlet 2.4 and above, you only need to add the following contextlistener to the XML:
< Web-app > ... < Listener > < Listener-class >org.springframework.web.context.request.RequestContextListener</ Listener-class> </listener> ... </web-app>
If you are Servlet2.4 a previous web container, you need to use a Javax.servlet.Filter implementation
<Web-app> .. <Filter> <Filter-name>Requestcontextfilter</Filter-name> <Filter-class>Org.springframework.web.filter.RequestContextFilter</Filter-class> </Filter> <filter-mapping> <Filter-name>Requestcontextfilter</Filter-name> <Url-pattern>/*</Url-pattern> </filter-mapping> ...</Web-app>
Annotations to @scope scopes in spring