http11.Http11OutputBuffer.SocketOutputBuffer.doWrite

这是一个错误。

我在spring框架中,创建了一个基类SuperBaseController,

并且使用了@ModelAttribute

用来给HttpServletRequest和HttpServletResponse赋值

但是,在前台调取接口返回大量图片时,报错:http11.Http11OutputBuffer.SocketOutputBuffer.doWrite

 

之后,我就在接口上单独加上了HttpServletRequest和HttpServletResponse(这两个值不需要传递),就好了

我猜测是@ModelAttribute多次执行的问题。

 

SuperBaseController如下

public class SuperBaseController {
	protected HttpServletRequest request;
	protected HttpServletResponse response;

	@ModelAttribute
	public void setLang(HttpServletRequest request, HttpServletResponse response) {
		this.request = request;
		this.response = response;
		
	}
}

接口如下:

@GetMapping(value = "downLitimg.do")
    public void downLitimg(String ArchiveDetailUUID,String YearMonth, HttpServletRequest request, HttpServletResponse response) {
        try {
            //获取Byte[] entity.getLitimgData()逻辑

            //返回图片
                BufferedImage image=ImageIO.read(new ByteArrayInputStream(entity.getLitimgData()));
                OutputStream out = response.getOutputStream();
                ImageIO.write(image, "jpg", out);
                out.flush();

                return;
            }else{
                System.out.println("图片加载没有数据C,getLitimgData=null"+ArchiveDetailUUID);
                return;
            }

            
        } catch (IOException ex) {
           ex.printStackTrace();
           return;
        }
    }

 

你可能感兴趣的:(spring)