在web項目中配置Spring的Ioc容器其實就是創建web應用的上下文(WebApplicationContext)
自定義要使用的IoC容器而不使用默認的XmlApplicationContext容器:
1 <context-param> 2 <param-name>contextConfigLocation</param-name> 3 <param-value>classpath:applicationContext.xml</param-value> 4 </context-param>
將IoC容器加載到Web容器中:
1 <listener> 2 <listener-class> 3 org.springframework.web.context.ContextLoaderListener 4 </listener-class> 5 </listener>
ContextLoaderListener完成WebApplicationContext的初始化
