spring-mvc - How to enable GZIP compression in Spring MVC with annotation on a controller class/method
问题描述
I'm researching migration from JAX-RS to Spring MVC and I stuck with GZIP.
In Apache CXF (one of JAX-RS implementation) it's possible to use @GZIP annotation at controller level that indicates that all resources in this class will be gzipped. From documentation:
This class is used to control GZIP compression of messages. Attaching this feature to an endpoint will allow the endpoint to handle compressed requests, and will cause outgoing responses to be compressed if the client indicates (via the Accept-Encoding header) that it can handle them.
I can't find how to do the same easily in Spring MVC. gzip is not mentioned in official documentation and answers like Using GZIP compression with Spring Boot/MVC/JavaConfig with RESTful show solutions for Spring Boot (not Spring MVC) that are application-wide (should be only for certain controllers).
Is there a simple solution for Spring MVC to enable GZIP compression by using annotation on a controller class/method. (maybe via custom message converter?)
解决方案
推荐阅读
- java - 当我在我的解压缩方法中运行我的压缩文件时添加了额外的字节
- python - 无法在熊猫中读取 Excel 文件
- android - groovy.lang.MissingPropertyException:无法获取未知属性“manifestOutputFile”
- django - Django - manage.py collectstatic 保存到错误的文件夹
- python - 如何在熊猫的数据框中添加索引
- python - pip install ... 不起作用:pip 配置了需要 TLS/SSL 的位置,但是 Python 中的 ssl 模块不可用
- python - RuntimeError:尺寸不匹配,m1:[32 x 1],m2:[32 x 9]
- javascript - 当 typeof 在函数上运行时,它返回“function”作为类型。为什么它不返回“对象”?
- ios - 使用 NavigationView 的模态演示
- azure-virtual-machine - terraform 报告错误“无法使用带有空列表的元素函数”