启动我的应用程序时出现此错误:


  java.io.FileNotFoundException:无法打开ServletContext资源
  [/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>

09-10 08:26
查看更多