1

I have a group of static files (mainly the static files, including css and images, that make up the ExtJS JavaScript framework). This group of static files rarely changes and therefore I decided NOT to include them within the items in the web application's war file. (I.e. I didn't follow the approach recommended by this answer.)

Right now I serve all these static files under /extjs by having the following Context container defined in server.xml:

<Context docBase="/path/to/extjs-4.1.1" path="/extjs" /> 

That "works" so far; still if anyone is able to suggest a better approach please do.

However I can't find a way to add expires HTTP headers to files served by this context.

Any idea how to configure Tomcat7 in this respect?

4

1 回答 1

0

Tomcat 的默认 servlet ( org.apache.catalina.servlets.DefaultServlet) 似乎没有办法做到这一点。

最简单的做法是创建一个 servlet 过滤器,它只是将您需要的 HTTP 标头添加到每个请求中。由于<context>定义了一个 webapp,你可以添加一个WEB-INF/web.xml文件/extjs并在那里加载你的过滤器。由于 /extjs 是一个单独的上下文,因此您的“真实”应用程序不会受到影响。

于 2012-09-20T23:40:37.390 回答