<servlet>
<servlet-name>dispatcher</servlet-name> <servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet>
<servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/index</url-pattern>
</servlet-mapping>
是因为拦截时遵循的是:
如果有匹配就拦截匹配的,找不到就直接拦截默认的(/)。
你这个中是有匹配的/index的
当在浏览器中输入如下url时,会被匹配到该servlet
http://.../index.html