How spring associates a beans scope with an HTTP scope such as a request, session, etc.

We have spring beans like:

@Component
@Scope(value="session")
public class MyBean {
    // ...
}

How internally, spring associates HTTP realms, such as a request, session with the corresponding bean realm. Is there a role for this RequestContextListener?

+4
source share
1 answer

RequestContextListener will associate the HTTP request object with the thread that serves this request. This makes beans available for request and session to further reduce call chains.

Even DispatcherServlet and RequestContextFilter will do the same

-1
source

Source: https://habr.com/ru/post/1610359/


All Articles