How do I apply a servlet filter when serving an HTML page directly?

大兔子大兔子 提交于 2019-12-05 15:27:03

You've probably configured html files to be served up as static content in your appengine-web.xml. Static file serving doesn't involve your app at all, so you can't filter the output.

If your need happens to be (like mine) to make GAE add certain http response headers for static HTML files, you can do this by declaring them as static resource in appengine-web.xml like this:

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

I found this in the GAE documentation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!