主頁(yè) > 知識(shí)庫(kù) > 用JSP下載word文件(不會(huì)直接用IE打開(kāi))

用JSP下載word文件(不會(huì)直接用IE打開(kāi))

熱門(mén)標(biāo)簽:Linux服務(wù)器 科大訊飛語(yǔ)音識(shí)別系統(tǒng) 服務(wù)器配置 阿里云 團(tuán)購(gòu)網(wǎng)站 銀行業(yè)務(wù) 電子圍欄 Mysql連接數(shù)設(shè)置

%@page import="java.util.*"%>
%@page import="java.io.*"%>
%@page import="java.net.*"%>
%
    String filename = "";
    if (request.getParameter("file") != null) {
        filename =     request.getParameter("file");
    }
    response.setContentType("application/msword");
    response.setHeader("Content-disposition","attachment; filename="+filename);

    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    try {
        bis = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath("" + filename)));
        bos = new BufferedOutputStream(response.getOutputStream());

        byte[] buff = new byte[2048];
        int bytesRead;

        while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
            bos.write(buff,0,bytesRead);
        }

    } catch(final IOException e) {
        System.out.println ( "出現(xiàn)IOException." + e );
    } finally {
        if (bis != null)
            bis.close();
        if (bos != null)
            bos.close();
    }
    return;
%>

您可能感興趣的文章:
  • JSP生成WORD文檔,EXCEL文檔及PDF文檔的方法
  • jsp頁(yè)面中顯示word/excel格式的文檔的方法
  • jsp導(dǎo)出excel并支持分sheet導(dǎo)出的方法
  • JSP導(dǎo)出Excel文件的方法
  • JSP上傳excel及excel插入至數(shù)據(jù)庫(kù)的方法
  • Jsp中的table多表頭導(dǎo)出excel文件具體實(shí)現(xiàn)
  • jsp實(shí)現(xiàn)針對(duì)excel及word文檔的打印方法

標(biāo)簽:江蘇 萍鄉(xiāng) 衢州 棗莊 衡水 大理 廣元 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《用JSP下載word文件(不會(huì)直接用IE打開(kāi))》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話(huà)咨詢(xún)

    • 400-1100-266