zoukankan      html  css  js  c++  java
  • spring中classpath

    http://blog.csdn.net/wlwlwlwl015/article/details/48134763

    Maven 项目的 classpath 理解

    applicationContext.xml放在maven的src/main/resources下,将web.xml中的<param-value>配置如下。

    <servlet>  
            <servlet-name>springMvc</servlet-name>  
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
            <init-param>  
                <param-name>contextConfigLocation</param-name>  
                <param-value>classpath:applicationContext.xml</param-value>  
            </init-param>  
            <load-on-startup>2</load-on-startup>  
        </servlet>  

    如下异常:Could not open ServletContext resource [/WEB-INF/applicationContext.xml

    原因:如果不特意指定参数名为contextConfigLoction的<context-parameter>元素,那么spring的ContextLoderListener监听器就会在/WEB-INF/下去寻找并加载该目录下的名为applicationContext.xml这个文件。

    解决:

    1 <context-param>  
    2         <param-name>contextConfigLocation</param-name>  
    3         <param-value>classpath:applicationContext.xml</param-value>  
    4     </context-param>  
    5   
    6     <listener>  
    7         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
    8     </listener>  
  • 相关阅读:
    软件补丁问题(网络流24题)
    飞行员配对方案问题(网络流24题)
    [NOIp普及组2011]瑞士轮
    如何在Linux上安装QQ
    [洛谷P2420] 让我们异或吧
    高斯消元
    [SCOI2014]方伯伯的OJ
    [USACO1.3]虫洞
    KMP算法讲解
    [洛谷P1382] 楼房
  • 原文地址:https://www.cnblogs.com/zhima-hu/p/8125221.html
Copyright © 2011-2022 走看看