如何解码Spring MVC中的Gzip压缩请求体 [英] How to decode Gzip compressed request body in Spring MVC

查看:610
本文介绍了如何解码Spring MVC中的Gzip压缩请求体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个发送数据的客户

I have a client that sends data with

CONTENT-ENCODING deflate

我有这样的代码

@RequestMapping(value = "/connect", method = RequestMethod.POST)
@ResponseBody
public Map onConnect(@RequestBody String body){}

目前'body'打印出乱码的压缩数据。
有没有办法让Spring MVC自动解压缩?

Currently 'body' prints out the garbled, compressed data. Is there any way to make Spring MVC automatically uncompress it?

推荐答案

你在Spring中没有处理它。相反,你使用过滤器,以便数据到达Spring已经缩小。

You don't handle it in Spring. Instead you use a filter so that the data arrives in Spring already deflated.

希望这两个链接可以帮助你开始。

Hopefully these two links can get you started.

  • http://www.javablog.fr/javaweb-gzip-compression-protocol-http-filter-gzipresponsewrapper-gzipresponsewrapper.html
  • http://srlawr.blogspot.com/2011/09/creating-custom-filter-in-spring.html

这篇关于如何解码Spring MVC中的Gzip压缩请求体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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