本帖最后由 qiuqiu_henry 于 2012-12-19 21:55:32 编辑

解决方案 »

  1.   

    大家看我这样写行吗?
    public void downloadCvs(List<RepairCatalogSearchResultsVO> rowDataList) throws CROSException{
       try{ 
       
      File file = new File("D:/results.csv");
      FileOutputStream out = new FileOutputStream(file);
      OutputStreamWriter osw = new OutputStreamWriter(out);
      BufferedWriter bw = new BufferedWriter(osw);
    //insert data 
      bw.write("ATA");
      bw.write(",");
      bw.write("componentDesc");
      bw.write(" ") ;
      bw.newLine();
      Iterator<RepairCatalogSearchResultsVO> ite = rowDataList.iterator();
    while (ite.hasNext()) {
    RepairCatalogSearchResultsVO vo = ite.next();
      bw.write(vo.getAtaNum());
      bw.write(",");
      bw.write(vo.getComponentDesc());
      bw.write(" ") ;
      bw.newLine();
    }
      //close
       bw.close();
       osw.close();
       out.close();
       }
      catch(Exception e){
       e.printStackTrace() ;
      }
    }
      

  2.   

    点击下载的时候把这些数据放到输出流中刷出来。就跟普通文件下载没什么区别,只是不用再去读文件而已。具体jsp下载文件网上很多例子,这里就不多说了。搜一下一大堆