2012-02-27 65 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