pom.xml에 ehcache-web 추가
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-web</artifactId>
<version>2.0.4</version>
</dependency>
web.xml에 filter 추가
<!-- gzip -->
<filter>
<filter-name>gzipFilter</filter-name>
<filter-class>net.sf.ehcache.constructs.web.filter.GzipFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>gzipFilter</filter-name>
<url-pattern>*.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>gzipFilter</filter-name>
<url-pattern>*.htm</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>gzipFilter</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>gzipFilter</filter-name>
<url-pattern>*.js</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>gzipFilter</filter-name>
<url-pattern>*.css</url-pattern>
</filter-mapping>
아쉬운 점은 filter를 mime-type으로 설정하는 게 없는 듯... (못찾겠다...)
mime-type으로 설정할 수 있으면 좋겠는데...
<url-pattern>/*</url-pattern> 이것 또한 안되고...
==================================================================================
단, Tomcat 7 부터는 압축을 자체 지원한다.
server.xml에 아래처럼 설정하면 mime-type을 지정할 수 있다. (톰캣 재시작)
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"
compressableMimeType="text/html,text/xml,text/plain,application/xml,application/json"
compression="on"
/>