在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的初始化

相关文章:

  • 2021-06-22
  • 2021-05-04
  • 2022-12-23
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-17
猜你喜欢
  • 2021-06-16
  • 2021-10-12
  • 2021-09-19
  • 2021-11-05
  • 2021-10-07
  • 2021-04-23
  • 2022-12-23
相关资源
相似解决方案