spring - What do ContextLoaderListener and RequestContextListener do? -


i have application, using spring. , in web.xml use lines below

<web-app>      ....      <listener>           <listener-class>              org.springframework.web.context.contextloaderlistener           </listener-class>        </listener>        <listener>           <listener-class>              org.springframework.web.context.request.requestcontextlistener           </listener-class>        </listener>        .... </web-app> 

what ? mandatory ?

org.springframework.web.context.contextloaderlistener class spring framework. implements servletcontextlistener interface, servlet container notifies @ startup (contextinitialized) , @ shutdown (contextdestroyed) of web application.

it in charge of bootstrapping (and orderly shutdown) spring applicationcontext.

ref: javadoc says:

bootstrap listener start , shut down spring's root webapplicationcontext. delegates contextloader contextcleanuplistener.

org.springframework.web.context.request.requestcontextlistener class same framework. javadoc says:

servlet 2.4+ listener exposes request current thread, through both localecontextholder , requestcontextholder. registered listener in web.xml.

alternatively, spring's requestcontextfilter , spring's dispatcherservlet expose same request context current thread. in contrast listener, advanced options available there (e.g. "threadcontextinheritable").

this listener use third-party servlets, e.g. jsf facesservlet. within spring's own web support, dispatcherservlet's processing sufficient.

so not used in spring mvc application, allows request or session scoped bean in jsf application using spring applicationcontext


Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -