【问题标题】:Spring MVC gzip compressionSpring MVC gzip 压缩
【发布时间】:2016-06-13 22:24:35
【问题描述】:

任何人都知道如何在 Spring MVC 的 Rest Controller 上启用 GZIP 压缩。 Tomcat 有这个特性,但是它将适用于所有 Restful API 的响应。我只想压缩某些 Restful API 的 HTTP 响应。

【问题讨论】:

    标签: spring-mvc gzip


    【解决方案1】:

    您可以使用以下方法实现它: http://www.javablog.fr/javaweb-gzip-compression-protocol-http-filter-gzipresponsewrapper-gzipresponsewrapper.html

    并将其应用于某些网址:

    if(httpRequest.getRequestURI().endsWith("/api/service")){//or similar verification
        //DO compression
    }else{
        chain.doFilter(request, response);
    }
    

    【讨论】:

      猜你喜欢
      • 2021-07-28
      • 1970-01-01
      • 2019-05-07
      • 2015-07-14
      • 2013-05-14
      • 2014-02-20
      • 2012-01-18
      • 1970-01-01
      相关资源
      最近更新 更多