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

1 回答 1

0

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

请检查您是否在response.getWriter()任何地方调用,或者请求是否登陆 JSP 写入response.getWriter().

于 2012-05-09T08:26:28.880 回答