SpringMVC中獲取數據庫圖片並顯示

@RequestMapping(value = "showImage/{id}", method = RequestMethod.GET)
    public ResponseEntity<byte[]> showImage(@PathVariable String id) throws IOException
    {
        byte[] zp = imageService.getImageById(id).getImage();
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.IMAGE_JPEG);
        return new ResponseEntity<byte[]>(zp, headers, HttpStatus.OK);
    }app

相關文章
相關標籤/搜索