Can we use multipart and @RequestBody together in spring?

后端 未结 4 1100
醉酒成梦
醉酒成梦 2021-02-20 06:00

I want to create a API which can have parameter as multipart file and JSON object (@RequestBody). Please find following snippet while calling this API. I am getting HTTP 415 Uns

4条回答
  •  清歌不尽
    2021-02-20 06:23

    When a parameter is annotated with @RequestPart the content of the part is passed through an HttpMessageConverter to resolve the method argument with the 'Content-Type' of the request part in mind. This is analogous to what @RequestBody does to resolve an argument based on the content of a regular request.

    so, we can parse @Requestbody as @RequestPart as "abaghel" and reportData need to be a json file.

提交回复
热议问题