zoukankan      html  css  js  c++  java
  • Web项目中加载Spring配置的常用方法

    1、web.xml中添加配置

    <web-app>  
       <context-param>  
          <param-name>contextConfigLocation</param-name>  
          <param-value>/WEB-INF/applicationContext-*.xml</param-value>  
          <!--<param-value>classpath*:applicationContext-*.xml</param-value>-->  
      </context-param>  
    <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
     </listener>  
    </web-app>  

    2、web.xml中添加配置

    <web-app>  
       <context-param>  
          <param-name>contextConfigLocation</param-name>  
          <param-value>/WEB-INF/applicationContext-*.xml</param-value>  
       </context-param>  
       <servlet>  
          <servlet-name>SpringContextServlet</servlet-name>  
          <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>  
          <load-on-startup>1</load-on-startup>  
       </servlet>  
    </web-app>  

    3、在(struts-config.xml)中加载

     <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">  
            <set-property property="contextConfigLocation"  
                value
    ="/WEB-INF/applicationContext.xml,  
                       /WEB-INF/action-servlet.xml"
    />  
     </plug-in>  
    坚持,坚持,再坚持。
  • 相关阅读:
    python3之面向对象实例存家具
    python3之面向对象实例烤地瓜
    python3之批量修改文件名称
    python3处理大文件
    利用函数的递归计算数字的阶乘
    windows10安装.netframework3.5
    centos7-django(python3)环境搭建
    centos7-django(python3)环境搭建!
    Java线程池
    python设置编码
  • 原文地址:https://www.cnblogs.com/walk-the-Line/p/4917627.html
Copyright © 2011-2022 走看看