如题,我该怎么实现

解决方案 »

  1.   

    没人回答?不用DownloadAction了,问同事讨了一个Action的。
      

  2.   

    response.reset();
    // 准备文件头
    response.addHeader("Content-disposition", " inline; filename=xzxy_"
    + fileName);
    response.setContentType(contentType); try {
    if (output == null) {
    output = response.getOutputStream();
    }
    if (fis == null) {
    fis = new FileInputStream(file);
    }
    byte[] b = new byte[1024];
    int i = 0; while ((i = fis.read(b)) > 0) {
    output.write(b, 0, i);
    }
    output.flush();
    } catch (Exception e) {
    log.warn(e);
    } finally {
    if (fis != null) {
    fis.close();
    fis = null;
    }
    if (output != null) {
    output.close();
    output = null;
    }
    }
    return null;