[英]IOException parsing XML document
Root Cause
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/web-inf/dispatcher-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/web-inf/dispatcher-servlet.xml]
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:344)
web.xml web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>spring-mvc-crud-demo</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>web-inf/dispatcher-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config>
</web-app>
Application can't find dispatcher-servlet.xml. 应用程序找不到dispatcher-servlet.xml。 I suppose that dispatcher-servlet.xml is in correct catalog. 我猜想dispatcher-servlet.xml在正确的目录中。
I have been searching stackOverFlow for a long time, but it doesn't help. 我一直在搜索stackOverFlow很长时间了,但这没有帮助。 This is very strange because it works on Windows, this problem appears on Mac. 这很奇怪,因为它在Windows上有效,而在Mac上出现此问题。
I am more used to writing WEB-INF in uppercase. 我更习惯于以大写形式编写WEB-INF。 Anyways try defining the location with a leading slash like this : 无论如何,尝试使用斜杠这样定义位置:
<param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.