2012-02-27 64 views
2

我正在使用Eclipse IDE和Google App Engine插件以及Guice。运行开发服务器上,我在web.xml试过这两个和吉斯MyServletModule extends ServletModule奇怪的Java Servlet筛选器映射行为

<url-pattern>/user/*</url-pattern> 

filter("/user/*").through(LoginFilter.class); 

似乎都为

http://www.domain.com/user/ 

但工作.. 。似乎不适用于:

http://www.domain.com/user/myaccount.html 

任何想法为什么?根据文档,/user/*应该适用于两者,对吗?

...我怀疑它与文件itaself有关,因为我似乎也无法过滤"*.html"

编辑已解决。唉...我发现这个珍闻在GAE/J文档: "Note: Filters are not invoked on static assets, even if the path matches a filter-mapping pattern. Static files are served directly to the browser."

回答

2

我发现这个珍闻在GAE/J文档:

Note: Filters are not invoked on static assets, even if the path matches a filter-mapping pattern. Static files are served directly to the browser. 

即使所有的Java Servlet文档说你可以做它,你不能在GAE/J中完成。

1

我发现,这种模式的工作原理:

<security-constraint> 
    <web-resource-collection> 
     <url-pattern>/myFile.html</url-pattern> 
    </web-resource-collection> 
    <auth-constraint> 
     <role-name>*</role-name> 
    </auth-constraint> 
</security-constraint> 

..所以如果你指定的或许是被过滤的文件!

+0

谢谢。是的,那些本地GAE约束确实有效,但是我需要添加对存储会话数据的自定义检查,这是我在筛选器中执行的操作,这些约束并未给我提供。我只是最终将我的静态* .html转换为* .jsp。 – DougA 2012-03-02 15:22:12