美文网首页
[springMVC]Could not open Servle

[springMVC]Could not open Servle

作者: Jacian | 来源:发表于2018-12-19 00:06 被阅读0次

    1. 问题描述

    搭建 Spring Web 项目时报错

    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/springmvc-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/springmvc-servlet.xml]

    2. 问题分析

    这里错误提示是没有加载成功 [springmvc-servlet.xml] 文件 , 但是我也没有配置加载这个文件

    3. 问题原因分析

    原因是在加载 SpringMVC 配置文件配置在了 [context-param] 标签中 , 无法加载springMvc 的过滤器 ; 出现上述加载文件失败的原因是 , 当在本目录找不到 web.xml 同目录下找不到 SpringMVC.xml 配置文件时 , spring 会自动去加载默认路劲下的配置文件 , 它找不到这个文件所以抛出如上错误 ;

    原因分析

    SpringMVC 配置文件的加载放在 [init-param] 标签中就能加载到 SpringMVC 自带的过滤器 ;

    SpringMVC配置文件加载

    相关文章

      网友评论

          本文标题:[springMVC]Could not open Servle

          本文链接:https://www.haomeiwen.com/subject/pszrkqtx.html