一尘不染

ava.lang.IllegalStateException:此响应已调用getOutputStream()

jsp

    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) {}

阅读 604

收藏
2020-06-10

共1个答案

一尘不染

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

请检查您是否正在呼叫response.getWriter()任何地方,或者该请求是否正在写入的JSP中进行response.getWriter()

2020-06-10