【发布时间】:2011-02-15 18:04:15
【问题描述】:
首先,我使用的是 Google AppEngine 和 Guice,但我怀疑我的问题与这些无关。
当用户连接到我的 (GWT) webapp 时,URL 是一个直接的 html 页面。例如,在开发模式下为:http://127.0.0.1:8888/Puzzlebazar.html?gwt.codesvr=127.0.0.1:9997。现在,我通过以下方式设置我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>PuzzleBazar</display-name>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Puzzlebazar.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--
This Guice listener hijacks all further filters and servlets. Extra
filters and servlets have to be configured in your
ServletModule#configureServlets() by calling
serve(String).with(Class<? extends HttpServlet>) and
filter(String).through(Class<? extends Filter)
-->
<listener>
<listener-class>com.puzzlebazar.server.guice.MyGuiceServletContextListener
</listener-class>
</listener>
</web-app>
而我的appengine-web.xml 是:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>puzzlebazaar</application>
<version>1</version>
<sessions-enabled>true</sessions-enabled>
<!-- Configure java.util.logging -->
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
</system-properties>
</appengine-web-app>
由于我使用的是 Guice,我必须在我的 ServletModule 中配置额外的过滤器,我这样做:
filter("*.html").through( SecurityCookieFilter.class );
但我的SecurityCookieFilter.doFilter 永远不会被调用。我尝试了"*.html*" 或<url-pattern>*</url-pattern> 之类的方法,但无济于事。知道我应该怎么做吗?
【问题讨论】:
-
我发现它可以通过切换到“.jsp”而不是“.html”来工作。
标签: google-app-engine tomcat gwt servlets guice