REST multipart mixed request (file+json) with Spring

前端 未结 4 2323
逝去的感伤
逝去的感伤 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:05

    It's maybe related to your request mapping annotation. I think accept value is missing to determine what service can accept :

    Example :

    @RequestMapping(path = "gopdf", method = RequestMethod.POST, consumes = { "multipart/mixed" }, accept = MediaType.MULTIPART_FORM_DATA_VALUE)
    

    Import :

    import org.springframework.http.MediaType;
    

    Documentation/API : http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/MediaType.html

提交回复
热议问题