日期:2014-05-16  浏览次数:20800 次

关于web.xml路径出错的问题
ssh框架里面,我的applicationContext.xml放在src下面。而我的web.xml文件在WebRoot/WEB-INF/lib/web.xml(即默认的目录下)
我在web.xml配置applicationContext.xml是这样写的
<context-param>
        <param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
启动Tomcat时报错,报错的部分内容如下
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist


麻烦各位大神指点一下!
web.xml Path

------解决方案--------------------
web.xml应该在WebRoot/WEB-INF/下,而不是在lib下面
web.xml里面写

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

------解决方案--------------------
web.xml应该在WebRoot/WEB-INF/下,而不是在lib下面
web.xml里面写

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