严重: Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response

解决方案 »

  1.   

    你看看你的代码,之前肯定有使用过IO流
    getOutputStream() has already been called for this response
    这句就说的很清楚
      

  2.   


    一Action中有方法:
    public void exportExcel() throws Exception {
    HttpServletResponse response = ServletActionContext.getResponse();
    response.reset();
    response.setContentType("application/vnd.ms-excel");
                    //把数据库中查询的数据用jxl写到excel中
                    //具体是写到response.getOutputStream()流中
                    WritableWorkbook wwb = Workbook.createWorkbook(response.getOutputStream());
                    //……
                    //然后返回此流到客户端下载
    }问题是:能直接打开生成的excel,但选择保存就出那个错了。
      

  3.   

    引用 1 楼 llpoo 的回复:你看看你的代码,之前肯定有使用过IO流
    getOutputStream() has already been called for this response
    这句就说的很清楚
      

  4.   

    WritableWorkbook wwb = Workbook.createWorkbook(response.getOutputStream());
    这句代码建议分解成
    OutputStream out=response.getOutputStream();
    WritableWorkbook wwb = Workbook.createWorkbook(out);
    out.fush();
    out.close();
      

  5.   

    楼主参考下面:
    http://blog.csdn.net/taochenpfj/archive/2009/07/08/4331928.aspx
    http://hi.baidu.com/jjpro/blog/item/9412ae23f3049b42ac34dec1.html
      

  6.   

    他说:“所以,就直接让action中的处理方法返回null,问题就解决啦!!!”
    但我的action中的方法返回类型都是void的,我也试了改成String然后return null。还是一样啊。
      

  7.   

    http://www.java2000.net/p1201
    看看这个。
      

  8.   

    如果LZ肯用百度和GOOGLE搜索的话 答案就会有一大堆http://www.khgl.cn/html/98/n-322298.html
      

  9.   

    是查过才问的呢。我就搞不明白一但点保存它就会重复调用exportExcel这方法。