如何为RestController启用GZIP?
发布时间:2020-12-15 04:45:15 所属栏目:Java 来源:网络整理
导读:参见英文答案 Using GZIP compression with Spring Boot/MVC/JavaConfig with RESTful????????????????????????????????????8个 我有一个使用spring的简单REST控制器. 如何启用返回的application / xml流的GZIP响应? @RestControllerpublic class MyRest {
参见英文答案 >
Using GZIP compression with Spring Boot/MVC/JavaConfig with RESTful????????????????????????????????????8个
我有一个使用spring的简单REST控制器. 如何启用返回的application / xml流的GZIP响应? @RestController public class MyRest { @RequestMapping(method = RequestMethod.GET,produces = MediaType.APPLICATION_XML_VALUE) @ResponseBody public ComplexRsp test() { //... } } 使用soap wsdl方法时,服务类上会有简单的@GZIP注释.如何为REST实现相同的目标? 解决方法
如果您正在使用Spring启动和Tomcat您应该能够通过Tomcat配置完成此任务:
http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#how-to-enable-http-response-compression 这是一个类似的POST Using GZIP compression with Spring Boot/MVC/JavaConfig with RESTful 它很简单如下: server.compression.enabled=true server.compression.mime-types=application/xml (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |