4

まず、私は 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*"orのようなことを試し<url-pattern>*</url-pattern>ましたが、役に立ちませんでした。これをどのように行うべきか考えていますか?

4

2 に答える 2

3

appengine-web.xmlで静的コンテンツとして提供されるようにhtmlファイルを設定した可能性があります。静的ファイルの提供にはアプリがまったく関与しないため、出力をフィルタリングすることはできません。

于 2010-05-05T15:50:29.917 に答える
1

たまたま (私のように) GAE に静的 HTML ファイルの特定の http 応答ヘッダーを追加させる必要がある場合は、次のように appengine-web.xml でそれらを静的リソースとして宣言することでこれを行うことができます。

<static-files>
  <include path="/my_static-files" >
    <http-header name="Access-Control-Allow-Origin" value="http://example.org" />
  </include>
</static-files>

これはGAEのドキュメントで見つけました

于 2016-02-23T19:25:27.167 に答える