web.xml中, 使用default servlet设置了针对静态资源后缀名的过滤. 并且设置了welcome-list, 使用jetty和tomcat6启动一切正常, 但是使用tomcat7则出现访问不到根节点(/)的情况.
后来将红色部分去掉后才正常.
原理和更优雅的解决方案:
Tomcat 6.0.30之前的security问题: https://issues.apache.org/bugzilla/show_bug.cgi?id=50026
使用spring的resource标签: http://docs.spring.io/spring/docs/3.0.5.RELEASE/spring-framework-reference/html/mvc.html#mvc-static-resources
不推荐使用容器自身的default servlet进行mapping: http://webmasters.stackexchange.com/questions/29550/why-the-difference-between-tomcat-and-tomcat7-regarding-servlet-mapping-and-defa
关于静态资源mapping的问题: http://stackoverflow.com/questions/870150/how-to-access-static-resources-when-using-default-servlet/3593513#3593513
<!-- 将几种最常用的静态资源配置在springServlet之前,提高访问速度 --> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.gif</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.eot</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.svg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.ttf</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.woff</url-pattern> </servlet-mapping> <!-- spring MVC configuration --> <servlet> <servlet-name>springServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:/spring/applicationContext-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>springServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.html</welcome-file> </welcome-file-list>