也许我只是缺少一些基本知识,但我无法弄清楚为什么 servlet 过滤器无法捕获对主 GWT 模块的 .html 文件的 GET 请求。
我的过滤器在 web.xml 中定义为
<filter>
<filter-name>GaeAuthFilter</filter-name>
<filter-class>com.test.GaeAuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>GaeAuthFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
当我在开发模式下启动应用程序时,它会打开 http://127.0.0.1:8888/AdminPanel.html?gwt.codesvr=127.0.0.1:9997在浏览器中,但没有任何东西被过滤器捕获:(
我需要这个的原因是我不希望我的身份验证在 RequestFactory ajax 调用时失败,因为它看起来很难看,因为它首先加载 html,然后重定向到 Google 帐户登录页面。我想在访问 html 页面时捕获未经身份验证的用户,这样浏览器甚至不会加载网站的 protected 区域。
作为替代方案,我尝试使用 web.xml 的“security-constraint”部分,但它也忽略了对 .html 文件的调用。
请指教。
谢谢!
最佳答案
来自 the AppEngine documentation :
Note: Static files, files that are served verbatim to users such as images, CSS or JavaScript, are handled separately from paths mentioned in the deployment descriptor. A request for a URL path that matches a path to a file in the WAR that's considered a static file will serve the file, regardless of servlet and filter mappings in the deployment descriptor. You can exclude files from those treated as static files using the appengine-web.xml file.
我不做 AppEngine,但我想添加一个 <exclude>
对于您希望应用过滤器的文件将执行此操作(这些文件将由默认 servlet 提供服务;我猜他们因此会以不同的方式计费)
关于java - 未在 GWT 模块的 .html 文件上调用 Servlet 过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7752543/