我的jsp页面有一个按钮,单击进入action查询数据然后导出excel,再跳转到但前页面显示查询出来的数据,
执行时报错:getOutputStream() has already been called for this response,在网上看的在页面写out.clear();
out = pageContext.pushBody();
,但没有用,请问我该怎么解决,谢谢!!!

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【Arthur3726】截止到2008-07-24 10:02:01的历史汇总数据(不包括此帖):
    发帖的总数量:15                       发帖的总分数:300                      每贴平均分数:20                       
    回帖的总数量:6                        得分贴总数量:1                        回帖的得分率:16%                      
    结贴的总数量:6                        结贴的总分数:120                      
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:9                        未结的总分数:180                      
    结贴的百分比:40.00 %               结分的百分比:40.00 %                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    楼主该结一些帖子了
      

  2.   

    你用到POI了吗,我现在正在研究,共同学习吧……
      

  3.   

    代码:
    /*************导出excel***************/
    if(outTag != null && "outYes".equals(outTag))//outTag==“outYes”则导出excel
    {
    String fName = "企业信息";
    if(action!=null && action.equals("cp"))
    {
    fName = "产品信息";
    }
    OutputStream os = response.getOutputStream();//取得输出流
    response.reset();//清空输出流
    response.setCharacterEncoding("UTF-8");
    fName = URLEncoder.encode(fName,"UTF-8");
    response.setHeader("Content-Disposition", "attachment; filename="+ new String(fName.getBytes("UTF-8"), "GBK") + ".xls");//扩展名为:.xls   
    response.setContentType("application/vnd.ms-excel");//定义输出类型excel:vnd.ms-excel,pdf:pdf

    InputStream is = null;
    File fileExcel = new File("D:/excel/mywritefile2.xls");//本地绝对路径
    try {
    if(fileExcel != null && !"".equals(fileExcel))
    {
    is = new FileInputStream(fileExcel);
    }
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    }
           byte[] buff = new byte[1024];//定义缓冲区
           int len;
           try {
    while((len = is.read(buff)) !=  -1) {//文件没到头
            os.write(buff, 0, len);
       }
    is.close();//关闭输入输出流
    os.close();  
    } catch (IOException e) {
    e.printStackTrace();
    }
    }
    /*************************************************/

    request.setAttribute("pageNo",pageNo);
    request.setAttribute("action",action);
    request.setAttribute("city",city );
    request.setAttribute("type", type);
    request.setAttribute("zhuangtai", zhuangtai);
    request.setAttribute("datetime", datetime);
    request.setAttribute("gjz", gjz);

    return new ActionForward("forward","/count/find/findshujujiansuo.jsp",false);