标签:
在web环境下(web.xml)如何配置applicationContext.xml文件
<listener>
  <listener-class>
   org.springframework.web.context.ContextLoaderListener
  </listener-class>
 </listener>
 或:
 <servlet>
  <servlet-name>context</servlet-name>
   <servlet-class>
    org.springframework.web.context.ContextLoaderServlet
   </servlet-class>
  <load-on-startup>1</load-on-startup>
 </servlet>
 通过如下方法取出applicationContext实例:
 ApplicationContext ac=WebApplicationContextUtils.getWebApplicationContext(this.getServletContext);
* 如何将spring加入web容器中
在web.xml中加入如下同容,在启动web服务器时加载/WEB-INF/applicationContext.xml中的内容。
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
通过如下类得到ApplicationContext实例
   WebApplicationContextUtils.getWebApplicationContext
Web环境下applicationContext.xml文件配置
标签:
原文地址:http://www.cnblogs.com/lsx1993/p/4631560.html