The configuration information for the spring Applicationcontext.xml is automatically assembled when the Web container is started.
Because it implements the Servletcontextlistener interface, when the Web. XML configures this listener, when the container is started, it executes the method it implements by default. The Contextloader class is associated with Contextloaderlistener, so the entire load configuration process is done by Contextloader.
Public classUserconfiglistenerextendsContextloaderlistener {protected FinalLog logger =Logfactory.getlog (GetClass ()); Public voidcontextinitialized (Servletcontextevent event) {Try{userconfig.getinstance (). Init (); } Catch(Exception e) {logger.error ("Initialization of user information error:", E); }} @Override Public voidcontextdestroyed (Servletcontextevent event) {//TODO auto-generated Method Stub Super. contextdestroyed (event); }
Contextinitialized: Default execution when starting
Spring:contextloaderlistener interface