简体   繁体   English

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

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

I'm trying build an app that takes a POST(with x-www-form-urlencoded header) with one parameter.我正在尝试构建一个带有一个参数的 POST(带有 x-www-form-urlencoded 标头)的应用程序。 This is my POST method code:这是我的 POST 方法代码:

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

When i do POST request by Postman with data "Let's measure"(image below) in method getTranslate text value is "Letâs measure".当我在方法 getTranslate 中使用数据“让我们测量”(下图)由邮递员发出 POST 请求时,文本值为“让我们测量”。 What am I doing wrong?我究竟做错了什么?

图片附件

I guess you have missed to add encoding in the header of your request- just add content-type & encoding and try:我猜您错过了在请求的标头中添加编码 - 只需添加内容类型和编码并尝试:

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

邮递员截图

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

相关问题 Spring application/x-www-form-urlencoded 防止字符串编码 - Spring application/x-www-form-urlencoded prevent encoding of string 如何使用 x-www-form-urlencoded 正文发送 post 请求 - How to send post request with x-www-form-urlencoded body 使用x-www-form-urlencoded的Jersey客户端发布请求失败 - Jersey client Post Request with x-www-form-urlencoded Fails 用于X-www-form-urlencoded输入请求的Spring bean - Spring bean for x-www-form-urlencoded typed request 内容类型为 application/x-www-form-urlencoded 的 HTTP Post 请求在 Spring 引导服务中不起作用 - HTTP Post request with content type application/x-www-form-urlencoded not working in Spring boot service 内容类型为 application/x-www-form-urlencoded 的 Http Post 请求在 Spring 中不起作用 - Http Post request with content type application/x-www-form-urlencoded not working in Spring 内容类型为 application/x-www-form-urlencoded 的发布请求在 Spring 中不起作用 - Post request with content type application/x-www-form-urlencoded not working in Spring POST x-www-form-urlencoded - POST x-www-form-urlencoded 泽西@FormParam字符串编码,带有x-www-form-urlencoded - Jersey @FormParam string encoding with x-www-form-urlencoded 如何使用Android批注和RestTemplate在POST请求的正文中发送x-www-form-urlencoded - How to send x-www-form-urlencoded in a body of POST request using android annotations and resttemplate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM