2

我在让Appstats正常工作时遇到问题。使用 /appstats 或 /appstats/stats 会导致无限循环,不断重定向回 /appstats/stats。这会导致 404 错误,说明页面未正确重定向。知道问题是什么吗?

以下是我的 web.xml 中的相关行。这与此处的文档基本相同。

<servlet>
    <servlet-name>appstats</servlet-name>
    <servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>appstats</servlet-name>
    <url-pattern>/appstats/*</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>appstats</filter-name>
    <filter-class>com.google.appengine.tools.appstats.AppstatsFilter</filter-class>
    <init-param>
        <param-name>logMessage</param-name>
        <param-value>Appstats available: /appstats/details?time={ID}</param-value>
    </init-param>
</filter>

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

<security-constraint>
    <display-name>appstatsConstraint</display-name>
    <web-resource-collection>
        <web-resource-name>appstatsCollection</web-resource-name>
        <url-pattern>/appstats/*</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>admin</role-name>
    </auth-constraint>
</security-constraint>

这是我的 appengine-web.xml 中的相关行。我试过同时使用 /appstats/stats 和 /appstats ,它们都有同样的问题。

<admin-console>
    <page name="Appstats" url="/appstats/stats" />
</admin-console>

以下是显示无限重定向循环的 http 标头:

http://mysite.appspot.com/appstats/stats

GET /appstats/stats HTTP/1.1
Host: mysite.appspot.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:
1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: USER_LOCALE=en_US; JSESSIONID=POTIUPPpEmjHZoaNDWOSTA;
ACSID=AJKiYcHiwT8jH7e01V9O5iFu3kpBhDd3k3oBwwxylv5u0DbJ-
utvdpsgdb4Xim2WXwobkJmgTGGljvuh94_yVQ__-
VPnBsTtUAhRjSyZ2Lv3G7oUHAxTsCWHJIMChGT3-
XUyUNx8wxwvJisL_RTXH8Hc4TTLh_rVHm2k8gk8kgdbVZXexSV0K-
a3coELTecWIBolt0qLd5L-5vALm382KsqbHorPXqoZMPTvR_06g_mR1cbmF2Ihnk6YhP7no58BNpESM9HvFyKNKXODo39hF4oaZCcW0Q9TBqUMgsrBqlcIh3-
VvC7qvH0n_nAtrLTBbK_swnOFvCDcaf3whT9ty0CJ0VRNuNqIPOLHIeQAMgwXUNMr89P64EsgmuyONHR67glCQXEPOGXIaT1vcBJFwFoeNUqjdp824fHvoVhaL7Xlav-
LTIFuM3f_ymHLmibk57PRuXUYEaAG

HTTP/1.1 302 Found
Location: http://mysite.appspot.com/appstats/stats
X-AppEngine-Estimated-CPM-US-Dollars: $0.645553
X-AppEngine-Resource-Usage: ms=18965 cpu_ms=27884 api_cpu_ms=0
Set-Cookie:
ACSID=AJKiYcF_YA7PB18b3T5OO7vEMo31f1hFhO8xKqFRiBUGrCr4YABAAyugZXcDfKMOM-
r0FiK8xlOPfQWx3tOWIJ6ueOqK89X8M9YfHIs8WKUcSs6PwNZSKV0HKxvbqeWxfZI_cpo2YoS73s_RPlyEvjaYLOf6iXPpWeYyKTAbSqPOEBnVnTk3oso6ur66CIj3FnN8vsHfbanqY4sbaRsNj9pLjWZco0quYLOK1fd4wRZx_oAvk3jOlfAj7BZ7p9L1bO8oVCMpVn19cwT6zvO2-9RSjfiOPAacw7Cg0MT30r7Fr7SCj7VcSPAye4lc7tb9KL9ztZEk0xbEX-9vC6vHM_VfPJ54Kb_FycxE6lACsKTE4hj0bOa2-2quaOP0NSxfoH9ozLlQQCsGhpWBnlu__W06D0GqDqxcDUu2HocYqWuLi91aoa-
aRTkqB_qo4aAa3OvHeKoFgwrS; expires=Mon, 12-Apr-2010 19:41:49 GMT;
path=/
Date: Sun, 11 Apr 2010 19:42:08 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Content-Type: text/html
Server: Google Frontend
Content-Length: 0
----------------------------------------------------------
http://mysite.appspot.com/appstats/stats

GET /appstats/stats HTTP/1.1
Host: mysite.appspot.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:
1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: USER_LOCALE=en_US; JSESSIONID=POTIUPPpEmjHZoaNDWOSTA;
ACSID=AJKiYcF_YA7PB18b3T5OO7vEMo31f1hFhO8xKqFRiBUGrCr4YABAAyugZXcDfKMOM-
r0FiK8xlOPfQWx3tOWIJ6ueOqK89X8M9YfHIs8WKUcSs6PwNZSKV0HKxvbqeWxfZI_cpo2YoS73s_RPlyEvjaYLOf6iXPpWeYyKTAbSqPOEBnVnTk3oso6ur66CIj3FnN8vsHfbanqY4sbaRsNj9pLjWZco0quYLOK1fd4wRZx_oAvk3jOlfAj7BZ7p9L1bO8oVCMpVn19cwT6zvO2-9RSjfiOPAacw7Cg0MT30r7Fr7SCj7VcSPAye4lc7tb9KL9ztZEk0xbEX-9vC6vHM_VfPJ54Kb_FycxE6lACsKTE4hj0bOa2-2quaOP0NSxfoH9ozLlQQCsGhpWBnlu__W06D0GqDqxcDUu2HocYqWuLi91aoa-
aRTkqB_qo4aAa3OvHeKoFgwrS

HTTP/1.1 302 Found
Location: http://mysite.appspot.com/appstats/stats
X-AppEngine-Estimated-CPM-US-Dollars: $0.002243
X-AppEngine-Resource-Usage: ms=64 cpu_ms=93 api_cpu_ms=0
Date: Sun, 11 Apr 2010 19:42:08 GMT
Content-Type: text/html
Server: Google Frontend
Content-Length: 0 
4

2 回答 2

2

事实证明,这是我在 web.xml 中也有的 URL 重写过滤器配置的问题。我必须确保没有匹配的规则/appstats/*。我将我的重写 urlrewrite.xml 编辑到下面。

<urlrewrite>
    <rule>
        <from>^(?!/appstats/)/(.*)$</from>
        <to last="true">/app/$1</to>
    </rule>
</urlrewrite>

/app/*是我的 Spring 调度程序 servlet 映射。

于 2010-04-12T00:26:59.580 回答
0

感谢您发布答案。在过去的一个小时里,我一直在寻找谷歌文档,试图找出问题所在,然后我在阅读你的帖子后意识到我有该死的 urlrewrite 过滤器设置!干杯!

于 2010-09-18T14:29:53.277 回答