【发布时间】:2012-02-24 20:56:23
【问题描述】:
我正在尝试将现有 Java Web 应用程序从 Tomcat 6 (6.0.32) 升级到 Tomcat 7 (7.0.23)。它是用 Spring MVC 和 Tiles 构建的。
大多数应用程序在 Tomcat 7 中运行良好,无需更改代码或配置。一个问题是主页坏了:Tomcat 7 显示我们的标准 404 页面而不是主页。网站上的其他页面看起来还不错。
日志显示问题在于某些东西(可能是 Tomcat)正在将 index.html 附加到主页请求。换句话说,当我导航到 URL http://localhost/ 时,Web 应用程序将其视为 http://localhost/index.html。这不起作用,因为我们没有 index.html,主页是动态生成的,并且应该由 Spring MVC 处理。
一些日志说明了这个问题。这些是点击主页时调试日志的前几行:
Tomcat 6
17:42:00.768 [TP-Processor3] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/'; against '/ws/**'
17:42:00.769 [TP-Processor3] DEBUG o.s.security.web.FilterChainProxy - / at position 1 of 11 in additional filter chain; firing Filter: 'ChannelProcessingFilter'
17:42:00.769 [TP-Processor3] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/'; against '/login'
17:42:00.769 [TP-Processor3] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/'; against '/login-process'
17:42:00.769 [TP-Processor3] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/'; against '/'
17:42:00.769 [TP-Processor3] DEBUG o.s.s.w.a.c.ChannelProcessingFilter - Request: FilterInvocation: URL: /; ConfigAttributes: [REQUIRES_INSECURE_CHANNEL]
17:42:00.770 [TP-Processor3] DEBUG o.s.security.web.FilterChainProxy - / at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
Tomcat 7
17:39:47.462 [ajp-bio-18009-exec-2] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/index.html'; against '/ws/**'
17:39:47.462 [ajp-bio-18009-exec-2] DEBUG o.s.security.web.FilterChainProxy - /index.html at position 1 of 11 in additional filter chain; firing Filter: 'ChannelProcessingFilter'
17:39:47.462 [ajp-bio-18009-exec-2] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/index.html'; against '/login'
17:39:47.462 [ajp-bio-18009-exec-2] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/index.html'; against '/login-process'
17:39:47.462 [ajp-bio-18009-exec-2] DEBUG o.s.s.web.util.AntPathRequestMatcher - Checking match of request : '/index.html'; against '/'
17:39:47.462 [ajp-bio-18009-exec-2] DEBUG o.s.security.web.FilterChainProxy - /index.html at position 2 of 11 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
据我所知,Tomcat 6 和 Tomcat 7 的配置方式相同,允许在版本之间更改一些默认配置。我仔细检查了<welcome-file-list> 在每一个中都完全相同。
那么是什么原因导致 index.html 被附加到 Tomcat 7 中的 URL 中?
【问题讨论】:
标签: java tomcat spring-mvc tomcat7