Could not open ServletContext resource [/WEB-INF/applicationContext.xml]解决方法

在整合spring,springMVC,hibernate的时候,因为从webinf的文件夹下移除了springMVC的配置文件到src下,所以,idea从默认的位置找不到配置文件,需要在web.xml指定地址。

原来的是:
  1. <servlet>
  2. <servlet-name>dispatcher</servlet-name>
  3. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  4. <load-on-startup>1</load-on-startup>
  5. </servlet>
  6. <servlet-mapping>
  7. <servlet-name>dispatcher</servlet-name>
  8. <url-pattern>*.form</url-pattern>
  9. </servlet-mapping>
加入地址:注意文件名<param-name>contextConfigLocation</param-name>,这里写错的,也加载不到
  1. <servlet>
  2. <servlet-name>dispatcher</servlet-name>
  3. <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  4. <init-param>
  5. <param-name>contextConfigLocation</param-name>
  6. <param-value>classpath:mvc_config.xml</param-value>
  7. </init-param>
  8. <load-on-startup>1</load-on-startup>
  9. </servlet>
  10. <servlet-mapping>
  11. <servlet-name>dispatcher</servlet-name>
  12. <url-pattern>*.form</url-pattern>
  13. </servlet-mapping>





posted @ 2016-03-30 15:47  奔跑吧_兄弟!  阅读(563)  评论(0编辑  收藏  举报