常规的servlet欢迎页使用如下:
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
那么其中的index.html一般都是作为静态html存在
那么不带后缀的RequestMapping作为欢迎页,那么需要将/index这个路径注册到原始的servlet中,而原始的servlet中可以存在不带后缀的映射,但依然无法使用前置/作为配置项,所以就需要将SpringMVC的/index映射为index,需要在web.xml中加入如下配置:
<servlet>
<servlet-name>dispatch</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
上面是一般都存在的,下面的就需要单独配置一次:
<servlet-mapping>
<servlet-name>dispatch</servlet-name>
<url-pattern>/index</url-pattern>
</servlet-mapping>
在配置欢迎页如下:
<welcome-file-list>
<welcome-file>index</welcome-file>
</welcome-file-list>
那么欢迎页实质就变成了http://域名/项目名/index