What is the role of contextloaderlistener

Time:2022-5-22

In every project that integrates the spring framework, it is always inevitable to be on the web Add such a configuration in XML.

contextConfigLocation
classpath:spring-config.xml

org.springframework.web.context.ContextLoaderListener

The function of contextloaderlistener is to read the XML file defined in contextconfiglocation when starting the web container, automatically assemble the configuration information of ApplicationContext and generate webapplicationcontext objects

Then place this object in the attribute of ServletContext, so that as long as we get the servlet, we can get the webapplicationcontext object, and use this object to access the beans managed by the spring container

Simply put, the above configuration provides spring support for the project and initializes the IOC container

Recommended Today

Build k8s clusters by kubedm

01 build k8s cluster Official website:https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/#installing-kubeadm-kubelet-and-kubectl GitHub:https://github.com/kubernetes/kubeadm In the course: use kubedm to build a k8s cluster composed of three machines, one master node and two worker nodes If your machine configuration is not enough, you can also use online, minicube or one master and one worker Configuration requirements: One or more machines running one […]