当前位置: 首页 > 工具软件 > smart-servlet > 使用案例 >

Could not open ServletContext resource [/WEB-INF/dispatcherservlet-servlet.xml]

齐迪
2023-12-01
今天在研究Spring mvc 的时候碰到了这样的一个问题:
Could not open ServletContext resource [/WEB-INF/dispatcherservlet-servlet.xml]

原因是我的web.xml里面是这样配置的:


[html]  view plain  copy
  1. <servlet>  
  2.     <servlet-name>dispatcherservlet</servlet-name>  
  3.     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  4.     <init-param>  
  5.         <param-name>springmvcconfig</param-name>  
  6.         <param-value>/WEB-INF/springmvc-config.xml</param-value>  
  7.     </init-param>  
  8.     <load-on-startup>1</load-on-startup>  
  9. </servlet>  
  10. <servlet-mapping>  
  11.     <servlet-name>dispatcherservlet</servlet-name>  
  12.     <url-pattern>*.do</url-pattern>  
  13. </servlet-mapping>  

这样配置的话,默认情况下回去读取dispatcherservlet-servlet.xml,所有改改配置才对。



[html]  view plain  copy
  1. <servlet>  
  2.     <servlet-name>dispatcherservlet</servlet-name>  
  3.     <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
  4.     <init-param>  
  5.         <param-name>contextConfigLocation</param-name>  
  6.         <param-value>/WEB-INF/springmvc-config.xml</param-value>  
  7.     </init-param>  
  8.     <load-on-startup>1</load-on-startup>  
  9. </servlet>  
  10. <servlet-mapping>  
  11.     <servlet-name>dispatcherservlet</servlet-name>  
  12.     <url-pattern>*.do</url-pattern>  
  13. </servlet-mapping>  


即:把


[html]  view plain  copy
  1. <param-name>contextConfigLocation</param-name>  

这里配置成这样才能读取到你配置的spring mvc 的配置


转载:http://blog.csdn.net/limingchuan123456789/article/details/8886095

参考:http://www.oschina.net/question/158170_38219

 类似资料: