繁体   English   中英

Spring - 使用 x-www-form-urlencoded 错误编码 POST 请求

[英]Spring - wrong encoding POST request with x-www-form-urlencoded

我正在尝试构建一个带有一个参数的 POST(带有 x-www-form-urlencoded 标头)的应用程序。 这是我的 POST 方法代码:

@RequestMapping(value = "/translate", method = RequestMethod.POST)
public String getTranslate(@RequestParam("text") String text) {
     //................      
}

当我在方法 getTranslate 中使用数据“让我们测量”(下图)由邮递员发出 POST 请求时,文本值为“让我们测量”。 我究竟做错了什么?

图片附件

我猜您错过了在请求的标头中添加编码 - 只需添加内容类型和编码并尝试:

Content-Type:application/x-www-form-urlencoded;charset=UTF-8

邮递员截图

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM