ava.lang.IllegalStateException:此响应已调用getOutputStream() [英] ava.lang.IllegalStateException: getOutputStream() has already been called for this response

查看:568
本文介绍了ava.lang.IllegalStateException:此响应已调用getOutputStream()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    String contenttype = rs.getString("contentType");
    String filename = rs.getString("fileName");

    response.setContentType(contenttype);
    response.setHeader("Content-disposition","attachment;filename=" + filename.replace('"', ' '));


    java.io.InputStream instream = rs.getBinaryStream("fileData");
    byte[] b = new byte[1000];
    while (instream.read(b) > 0) {
        try {
            response.getOutputStream().write(b);
        }
        catch(Exception e) {}
    }

    try {
        response.getOutputStream().flush();
    }
    catch(Exception e) {}

推荐答案

通常,它应允许多次调用response.getOutputStream().我认为您同时呼叫response.getOutputStream()response.getWriter().

Normally, it should allow calling response.getOutputStream() any number of times. I think you are calling both response.getOutputStream() and response.getWriter().

请检查您是否在任何地方调用response.getWriter()或该请求是否正在写入response.getWriter()的JSP中着陆.

Please check if you are calling response.getWriter() anywhere or is the request is landing in JSP which writes to response.getWriter().

这篇关于ava.lang.IllegalStateException:此响应已调用getOutputStream()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆