我目前正在使用Spring框架构建一个简单的REST服务。但是在使用Postman进行测试时,我遇到了以下问题:Click to view image
我不知道如何使Spring识别接收到的Content-Type标头实际上与application/x-www-form-urlencoded
相匹配,这受支持。
更新:
我目前在localhost
的嵌入式Tomcat服务器上运行我的应用程序。
我的端点简要包括:
/api/users
-用于创建新用户/api/users
-用于列出用户/api/users/{id}
-用于通过其ID检索用户POST端点的请求正文:
"email":"<your-email>",
"password:"<your-password>"
更新2:
尝试一下:
@PostMapping(path = "/api/users",consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE})
public ResponseEntity<String> createUser(@RequestBody User user)