我正在尝试构建一个应用程序,该应用程序采用带有一个参数的 POST(带有 x-www-form-urlencoded header )。 这是我的 POST 方法代码:
@RequestMapping(value = "/translate", method = RequestMethod.POST)
public String getTranslate(@RequestParam("text") String text) {
//................
}
当我通过 Postman 在方法 getTranslate 中使用数据“让我们测量”(下图)执行 POST 请求时,文本值为“让我们测量”。 我做错了什么?
最佳答案
我猜您错过了在请求 header 中添加编码 - 只需添加内容类型和编码并尝试:
Content-Type:application/x-www-form-urlencoded;charset=UTF-8
关于java - Spring - 使用 x-www-form-urlencoded 编码 POST 请求错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54924941/