启动应用程序时出现此错误
When I launch my application I get this error
java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SpringDispatcher-servlet.xml] nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SpringDispatcher-servlet.xml]同时,我没有像SpringDispatcher-servlet.xml这样的文件,我的web.xml或mvc-dispatcher-servlet.xml文件中也没有我的WEB-INF文件夹。
Meanwhile, I dont have any file like SpringDispatcher-servlet.xml neither do I in my web.xml or mvc-dispatcher-servlet.xml file defined in my WEB-INF folder.
web.xml文件
<context-param> <param-name>contextClass</param-name> <param-value> org.springframework.web.context.support.AnnotationConfigWebApplicationContext </param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>SpringDispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>SpringDispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value> </context-param> <session-config> <session-timeout>30</session-timeout> </session-config>mvc-dispatcher-servlet.xml文件
<context:component-scan base-package="aish.vaishno.musicstore.controller" /> <mvc:annotation-driven /> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/view/" /> <property name="suffix" value=".jsp" /> </bean>请问如何找到该文件
/WEB-INF/SpringDispatcher-servlet.xml请我怎么了?
推荐答案在您的web.xml中,您已将servlet定义为
In your web.xml you have define the servlet to be
<servlet> <servlet-name>SpringDispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> </servlet>因此,您需要创建一个名为 SpringDispatcher-servlet.xml 的文件在您的 WEB-INF 文件夹中。这就是它的工作原理。如果将servlet名称更改为调度程序,则文件名应为dispatcher-servlet.xml。 您的SpringDispatcher-servlet.xml包含您的Spring上下文的定义。看看这个教程。
therefore, you nee to create a file named SpringDispatcher-servlet.xml inside your WEB-INF folder. This is just how it works. If you change the servlet-name to be dispatcher then the file name should be dispatcher-servlet.xml. Your SpringDispatcher-servlet.xml contains the definitions of your spring context. Take a look on this tutorial.
更多推荐
java.io.FileNotFoundException:无法打开ServletContext资源[/WEB
发布评论