使用Java Servlets提供Gzip压缩内容 [英] Serve Gzipped content with Java Servlets

查看:103
本文介绍了使用Java Servlets提供Gzip压缩内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种 easy 方式来使用Java Servlets提供GZipped内容。我已经启动并运行了应用程序,因此所需的修改应该太重了。

I was wondering if there was an easy way to serve GZipped content with Java Servlets. I already have the app up and running so the modifications needed should be too heavy.

我可以在doPost / doGet方法结束时访问响应对象,所以我正在寻找像

I have access to the response object just at the end of the doPost/doGet method, so I'm looking for something like

response.setGzip(true);

它不一定那么简单但它会是理想的。

It doesn't have to be that easy but it would be ideal.

非常感谢

推荐答案

本文包含自动压缩的ServletFilter的完整(和简要)源代码在飞行中。

This article has the complete (and brief) source code for a ServletFilter that automatically compresses on the fly.

这篇关于使用Java Servlets提供Gzip压缩内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆