我在启动我的应用程序时收到此错误:
java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/spring/servlet/servlet-context.xml]
我不知道为什么 Spring 正在搜索 servlet-context.xml 。我所有的上下文都在 web-inf/context/portlet 中配置 是否有我可以添加到 web.xml 的设置,以便 tomcat 可以将上下文从不同的目录解析为/WEB-INF/spring/servlet/servlet-context.xml ?还是解决此问题的另一种方法?
最佳答案
通常您在WEB-INF/web.xml 文件中设置上下文的位置,参见此处: http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#web-integration-common
因此您的 WEB-INF/web.xml 文件应该类似于,仔细检查 contextConfigLocation 值是否指向您的上下文配置文件:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/context/portlet/*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
关于spring - 如何更改找到 bean 的上下文路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13162815/