java

关注公众号 jb51net

关闭
首页 > 软件编程 > java > spring web.xml

spring web.xml指定配置文件过程解析

作者:泡椒炒甜瓜

这篇文章主要介绍了spring web.xml指定配置文件过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

这篇文章主要介绍了spring web.xml指定配置文件过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classpath:spring-beans.xml</param-value>
</context-param>

指定多个配置文件用,隔开。

<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

在web应用启动的,ContextLoaderListener读取contextConfigLocation中定义的xml文件,自动装配ApplicationContext的配置信息,

并产生WebApplicationContext对象,然后将这个对象放置在ServletContext的属性里,

这样我们就可以在servlet里得到WebApplicationContext(spring容器上下文)对象。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文