REST multipart mixed request (file+json) with Spring

前端 未结 4 2324
逝去的感伤
逝去的感伤 2021-02-20 12:37

I need to send a file alongside with a json to my Spring Controller. I have the following controller class:

@Controller
@RequestMapping(\"/perform\")
public cla         


        
4条回答
  •  面向向阳花
    2021-02-20 13:03

    I've found the solution: I need to use @RequestParam instead of @RequestPart

    @RequestMapping(path = "gopdf", method = RequestMethod.POST, consumes = { "multipart/form-data" })
    @ResponseStatus(HttpStatus.OK)
    public void handleFileUpload2(@RequestParam("file") MultipartFile file, @RequestParam("map") String jsonMap,
            HttpServletResponse response) throws Exceptio
    

提交回复
热议问题