0

我有一个使用基本 jsp 和 servlet 的简单 Web 应用程序。我有一个映射到 /* 的 servlet 过滤器。我有一个配置为 index.jsp 的欢迎文件

<filter-mapping>
    <filter-name>ObjectifyFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

...

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

我遇到的问题是,当对不存在的资源的请求并且在应用程序引擎上部署时应该返回 404 错误时,在尝试重复附加斜杠 + 欢迎文件时无休止地返回 302。

EG:对http://myyapp.appspot.com/foo的请求(没有为 foo 配置任何内容)会产生以下结果:

http://myyapp.appspot.com/foo/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index。 jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/index.jsp/

在开发服务器上,这将返回预期的 404。如果我删除过滤器映射,它也会在应用引擎上返回 404。

这似乎相当基本,所以我猜我在某个地方错过了一些东西。有任何想法吗?

4

1 回答 1

0

看起来问题的一个重要因素是 web.xml 中的 jsp-config 标记。虽然我认为内容无关紧要,但我的看起来像这样:

<jsp-config>
    <jsp-property-group>
        <url-pattern>*.jsp</url-pattern>
        <page-encoding>UTF-8</page-encoding>
    </jsp-property-group>
</jsp-config>

删除 jsp-config 标记为我解决了这个问题,即它是一种解决方法。就我而言,它并没有造成太大的伤害,因为我可以分别在每个页面上指定页面编码。但是我仍然对真正的解决方案感兴趣。

于 2013-01-14T21:05:38.553 回答