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

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

问题描述

我有一个用

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.

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

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