[英]spring framework nesting java.io.FileNotFoundException:
我想運行我的第一個 web 應用程序,但出現此錯誤
我已經搜索了 web 但我無法弄清楚問題所在。 我試圖用谷歌搜索什么是嵌套,但我不明白它在說什么
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/todo-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/todo-servlet.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
web.xml
todo-servlet 的路徑在此處配置。
<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/todo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/spring-mvc/*</url-pattern>
</servlet-mapping>
我在 src/main/webapp/WEB-INF/todo-servlet.xml 中創建了 todo-servlet.xml 但我仍然收到文件未找到異常
請參閱下面的鏈接並按照 xml 以及 class 和文件路徑位置中的逐步檢查配置。
http://websystique.com/springmvc/spring-4-mvc-helloworld-tutorial-full-example/
This usually happens in a Spring Web application, when a DispatcherServlet is set up in the web.xml for Spring MVC. By default, Spring will look for a file called exactly springMvcServlet-servlet.xml in the /WEB-INF directory of the web application.mvc-servlet.xml file that indeed exists under /WEB-INF.
或者它可能會發生,因為當應用程序中的某些內容指向不存在或未放置在應有位置的 XML 資源時。 創建文件並將其放在項目的 /src/main/resources 目錄下——這樣,文件將存在於類路徑中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.