现在的位置: 首页 > 综合 > 正文

spring ClassPathXmlApplicationContext

2017年01月09日 ⁄ 综合 ⁄ 共 525字 ⁄ 字号 评论关闭

 spring为ApplicationContext提供3种实现分别为:

ClassPathXmlApplicationContext(默认是加载src下面的spring配置文件),

FileSystemXmlApplicationContext(参数为路径)和XmlWebApplicationContext,

其中XmlWebApplicationContext是专为Web工程定制的。

 ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext()); 



在ssh整合时,web.xml里加入spring监听,

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

此时,默认会去/WEB-INF/下加载applicationContext.xml。 

若要修改该配置文件位置,可以通过.<context-param>  参数来改变。






抱歉!评论已关闭.