<web:context-param> <web:param-name>contextConfigLocation</web:param-name> <web:param-value>classpath:spring/applicationContext.xml</web:param-value> </web:context-param> <web:listener> <web:listener-class>org.springframework.web.context.ContextLoaderListener</web:listener-class> </web:listener> <web:listener> <web:listener-class>org.springframework.web.util.IntrospectorCleanupListener</web:listener-class> </web:listener> <web:servlet> <web:servlet-name>springmvc</web:servlet-name> <web:servlet-class>org.springframework.web.servlet.DispatcherServlet</web:servlet-class> <web:init-param> <web:param-name>contextConfigLocation</web:param-name> <web:param-value>classpath:spring/springmvc.xml</web:param-value> </web:init-param> <web:load-on-startup>1</web:load-on-startup> </web:servlet> <web:servlet-mapping> <web:servlet-name>springmvc</web:servlet-name> <web:url-pattern>/</web:url-pattern> </web:servlet-mapping> |
使用上面这种配置是不行的。
把web: 去掉
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <servlet> <servlet-name>springmvc</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/springmvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springmvc</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> |