spring 方法参数类型String所需的请求参数“image”不存在

wko9yo5t  于 2023-01-08  发布在  Spring
关注(0)|答案(1)|浏览(225)

我有一个问题与spring http方法

@PutMapping("/book/photo/{id}")
    public ResponseEntity<?> updatePhoto(@PathVariable("id") long id, @RequestParam("image") String image)
    {
        try
        {
            bookService.updateImage(id,null);
        }
        catch (BadRequestIdException e)
        {
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(e.getMessage());
        }
        return ResponseEntity.ok("PHOTO WAS UPDATED");
    }

enter image description here
当我运行这个 Postman 我得到回应
2021 - 07 - 09 12:17:52.768警告2860---[nio-8080-exec-2]. w.s.m.s.默认处理程序异常解决程序:已解决[组织。springframework。web。绑定。缺少服务请求参数异常:方法参数类型String所需的请求参数"image"不存在]
为什么它不工作?

vuktfyat

vuktfyat1#

看起来您向接受字符串的控制器发送了二进制数据。如果不是这种情况,则此错误也可能是由于超时或网络丢失导致控制器接收到部分有效负载所致。

相关问题