尝试在春天拍摄图像时出现403错误

时间:2014-11-24 05:04:43

标签: java spring web-services http-status-code-403

我已经编写了一个简单的REST-API示例,可以在有请求时获取并进行映像。以下是java代码(我使用Spring构建REST-API)

@RequestMapping(value = "/image/{itemId}",
        headers = "Accept=image/jpeg, image/jpg, image/png, image/gif",
        produces = "image/jpg",
        method = RequestMethod.GET)
@ResponseBody
public BufferedImage getChequeImage(HttpSession session, @PathVariable int itemId, HttpServletResponse response) {
    try{
        InputStream newStream = new BufferedInputStream(new FileInputStream("C:\\images\\1409830712475-c9df8fe0-290e-4523-909d-c2f909eb564a.jpg"));
        return ImageIO.read(newStream);
    }catch (IOException e){
        LOGGER.error(e.getMessage(), e);
        //return ResponseHandler.sendErrorResponse(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), response);
        throw new RuntimeException(e);
    }
}

这将返回 403禁止响应消息。有人可以请帮忙。

0 个答案:

没有答案