Spring在Web.xml中的配置

来源:互联网 发布:打装备手机游戏 知乎 编辑:程序博客网 时间:2024/05/04 19:55
<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  <!-- default: /WEB-INF/applicationContext.xml -->
 </listener>
 <!-- ContextLoaderListener预设会读取applicationContext.xml -->
 <!--
  可以在自定义的Servlet中使用 org.springframework.web.context.support.WebApplicationContextUtils,
  从 ServletContext中取得org.springframework.web.context.WebApplicationContext,
  例如:  
  WebApplicationContext ctx =  WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
  UserDao date = (UserDao)ctx.getBean("userDao");
  -->
 <context-param>
  <param-name>contextConfigLocation</param-name>
  <!--
   <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
  -->
  <param-value>classpath:beans.xml</param-value>
 </context-param>