HttpMediaTypeNotAcceptableException: Could not find acceptable representation in exceptionhandler

前端 未结 2 471
梦如初夏
梦如初夏 2020-12-01 18:27

I have the following image download method in my controller (Spring 4.1):

@RequestMapping(value = \"/get/image/{id}/{fileName}\", method=RequestMethod.GET)
p         


        
2条回答
  •  盖世英雄少女心
    2020-12-01 18:56

    Pay attention to your HTTP Accept header. For example, if your controller produces "application/octet-stream" (in response), your Accept header should NOT be "application/json" (in request):

    @GetMapping(value = "/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
    public void download(HttpServletResponse response) {}
    

提交回复
热议问题