好的,我是第500个用户问这个问题,我读了很多答案但仍然没有运气。
Ok, I am 500th user asking this question, I read many answers but still having no luck.
父模块pom包含:
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.framework.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.framework.version}</version> </dependency>子模块有 maven-jetty-plugin 然后我用 jetty运行我的webapp模块:运行。
web.xml 定义标准调度程序模块:
web.xml defines standard dispatcher module:
<listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>我有文件 dispatcher-servlet.xml 在 WEB-INF 下,虽然启动失败:
I have file dispatcher-servlet.xml under WEB-INF, though start fails with:
FileNotFoundException: Could not open ServletContext resource [/WEB-INF/applicationContext.xml]有什么问题?文档和每个人都说Spring MVC将搜索XX-servlet.xml,其中XX是servlet的名称。为什么要搜索 applicationContext.xml ?
What is wrong? Documentation and everybody says that Spring MVC will search for XX-servlet.xml, where XX is name of servlet. Why does it search for applicationContext.xml?
推荐答案ContextLoaderListener 有自己的上下文,由所有servlet和过滤器共享。默认情况下,它将搜索 /WEB-INF/applicationContext.xml
ContextLoaderListener has its own context which is shared by all servlets and filters. By default it will search /WEB-INF/applicationContext.xml
您可以使用
You can customize this by using
<context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/somewhere-else/root-context.xml</param-value> </context-param>在 web.xml 上,或删除此项听众,如果你不需要。
on web.xml, or remove this listener if you don't need one.
更多推荐
无法打开ServletContext资源[/WEB
发布评论