【发布时间】:2022-07-01 21:47:16
【问题描述】:
我在 Spring Boot Restcontroller 中有一个 POST API,它接受一个字符串并返回该字符串。但是收到的字符串值具有特殊字符,例如“=”
@RestController
public class MyApi{
@PostMapping(path = "/", consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public String parseInput(@RequestBody String data) {
return data;
}
}
curl -d "1" http://localhost:1337/ 给出1= 而不是1
【问题讨论】:
-
我可以知道如何删除填充字符吗?
-
如果在 cURL 中使用
--data-binary而不是-d会发生什么?请参阅What does the -d in this cURL command mean? 和Curl -d vs --data-binary。您可能还需要设置content-type。
标签: java spring-boot rest