研究IOC首先創(chuàng)建一個(gè)簡單的web項(xiàng)目,在web.xml中我們都會(huì)加上這么一句
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
這代表了web容器啟動(dòng)的時(shí)候會(huì)首先進(jìn)入ContextLoaderListener這個(gè)類,并且之后會(huì)去加載classpath下的applicationContext.xml文件。那么重點(diǎn)就在ContextLoaderListener上,點(diǎn)開源碼:
/** * Initialize the root web appli