简体   繁体   English

过滤器未对web.xml中的欢迎页面执行

[英]Filter not executing for welcome page in web.xml

I'm attempting to follow these instructions to make my GWT/App Engine app crawlable. 我试图按照以下说明进行操作,以使我的GWT / App Engine应用程序可抓取。 I built a filter as described, and included the following in my web.xml: 我按照说明构建了一个过滤器,并将以下内容包含在我的web.xml中:

  <filter>
     <filter-name>crawlFilterChain</filter-name>
     <filter-class>com.project.name.server.service.CrawlFilterChain</filter-class>
  </filter>


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

  <welcome-file-list>
     <welcome-file>BaconBits.html</welcome-file>
  </welcome-file-list>

I then attempted to test the configuration by loading this URL in a browser: 然后,我尝试通过在浏览器中加载以下URL来测试配置:

http://127.0.0.1:8888/?gwt.codesvr=127.0.0.1:9997&_escaped_fragment_=page%3DEvent%26eventId%3D1138 http://127.0.0.1:8888/?gwt.codesvr=127.0.0.1:9997&_escaped_fragment_=page%3DEvent%26eventId%3D1138

The filter is invoked, but not for the initial "GET /" request when the page is first loaded (the one that returns the welcome file). 首次加载页面(返回欢迎文件的页面)时,将调用过滤器,但不会调用初始的“ GET /”请求。 It's only invoked for subsequent RPC/AJAX requests, none of which have a query string. 它仅用于后续的RPC / AJAX请求,而这些请求都没有查询字符串。 Oddly, if I insert a non-existent resource after the / in the URL (such as index.html), the filter is invoked, and the appropriate HTML is returned. 奇怪的是,如果我在URL中的/之后插入不存在的资源(例如index.html),则会调用过滤器,并返回适当的HTML。 What am I doing wrong? 我究竟做错了什么? The behavior is the same in production. 生产中的行为是相同的。

This looks to be the same problem described here and here , but using the same config as they recommend doesn't work. 这似乎是此处此处所述的相同问题,但是无法使用他们建议的相同配置。 Basically, the "GET /" request that returns the welcome file doesn't invoke the filter. 基本上,返回欢迎文件的“ GET /”请求不会调用过滤器。 What am I doing wrong? 我究竟做错了什么?

好的, 这篇文章是同样的问题,appengine-web.xml自我解答对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM