今天在研究Spring mvc 的时候碰到了这样的一个问题:
Could not open ServletContext resource [/WEB-INF/dispatcherservlet-servlet.xml]
原因是我的web.xml里面是这样配置的:
- <servlet>
- <servlet-name>dispatcherservlet</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>springmvcconfig</param-name>
- <param-value>/WEB-INF/springmvc-config.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>dispatcherservlet</servlet-name>
- <url-pattern>*.do</url-pattern>
- </servlet-mapping>
这样配置的话,默认情况下回去读取dispatcherservlet-servlet.xml,所有改改配置才对。
- <servlet>
- <servlet-name>dispatcherservlet</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/springmvc-config.xml</param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>dispatcherservlet</servlet-name>
- <url-pattern>*.do</url-pattern>
- </servlet-mapping>
即:把
- <param-name>contextConfigLocation</param-name>
这里配置成这样才能读取到你配置的spring mvc 的配置
转载:http://blog.csdn.net/limingchuan123456789/article/details/8886095
参考:http://www.oschina.net/question/158170_38219