<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Java學習

    java,spring,structs,hibernate,jsf,ireport,jfreechart,jasperreport,tomcat,jboss -----本博客已經搬家了,新的地址是 http://www.javaly.cn 如果有對文章有任何疑問或者有任何不懂的地方,歡迎到www.javaly.cn (Java樂園)指出,我會盡力幫助解決。一起進步

     

    用JSP生成HTM網頁,減輕數據庫操作!

    模本頁面:template.htm
    <html>
    <head>
    <title>###title###</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <LINK href="../css.css" rel=stylesheet type=text/css>
    </head>

    <body>
    <table width="500" border="0" align="center" cellpadding="0" cellspacing="2">
    <tr>
    <td align="center">###title###</td>
    </tr>
    <tr>
    <td align="center">作者:###author###  </td>
    </tr>
    <tr>
    <td>###content###
    </td>

    </tr>

    </table>
    </body>
    </html>

    =========================================
    JSP文件: buildhtml.jsp

    <%@ page contentType="text/html; charset=gb2312" import="java.util.*,java.io.*"%>
    <%
    try{
    String title="jsp生成靜態html文件";
    String content="小樣,還搞不定你?";
    String editer="hpsoft";
    String filePath = "";
    filePath = request.getRealPath("/")+"template.htm";
    out.print(filePath);
    String templateContent="";
    FileInputStream fileinputstream = new FileInputStream(filePath);//讀取模塊文件
    int lenght = fileinputstream.available();
    byte bytes[] = new byte[lenght];
    fileinputstream.read(bytes);
    fileinputstream.close();
    templateContent = new String(bytes);
    out.print(templateContent);
    templateContent=templateContent.replaceAll("###title###",title);
    templateContent=templateContent.replaceAll("###content###",content);
    templateContent=templateContent.replaceAll("###author###",editer);//替換掉模塊中相應的地方
    out.print(templateContent);
    // 根據時間得文件名
    Calendar calendar = Calendar.getInstance();
    String fileame = String.valueOf(calendar.getTimeInMillis()) +".html";
    fileame = request.getRealPath("/")+fileame;//生成的html文件保存路徑
    FileOutputStream fileoutputstream = new FileOutputStream(fileame);//建立文件輸出流
    out.print("文件輸出路徑:<br>");
    out.print(fileame);
    byte tag_bytes[] = templateContent.getBytes();
    fileoutputstream.write(tag_bytes);
    fileoutputstream.close();
    }
    catch(Exception e){
    out.print(e.toString());
    }

    %>

    posted on 2009-04-29 16:11 找個美女做老婆 閱讀(197) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發表評論。


    網站導航:
     

    導航

    統計

    公告

    本blog已經搬到新家了, 新家:www.javaly.cn
     http://www.javaly.cn

    常用鏈接

    留言簿(6)

    隨筆檔案

    文章檔案

    搜索

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲AV成人一区二区三区在线看| 亚洲精品字幕在线观看| 亚洲免费观看在线视频| 久久久久久国产精品免费免费男同 | 在线观着免费观看国产黄| 久久精品国产亚洲αv忘忧草| 99精品视频在线观看免费播放| 亚洲AV无码日韩AV无码导航| 久久久精品免费视频| 亚洲av无码成h人动漫无遮挡 | 99热在线免费观看| 亚洲高清无在码在线无弹窗| 69式国产真人免费视频| 亚洲天堂免费在线| 日韩视频免费一区二区三区| 免费的黄色网页在线免费观看| 亚洲国产精品毛片av不卡在线| 久久久久国色AV免费观看| 亚洲AV电影院在线观看| **一级毛片免费完整视| 亚洲中文字幕无码久久2020| 国产一级一片免费播放i| gogo免费在线观看| 亚洲第一区香蕉_国产a| 青草草色A免费观看在线| 亚洲AV无码成人精品区日韩| 亚洲情侣偷拍精品| 日韩在线永久免费播放| 亚洲 日韩 色 图网站| 无码欧精品亚洲日韩一区夜夜嗨 | 国产一区二区三区在线观看免费| 国产成人 亚洲欧洲| 中文字幕亚洲无线码| 曰批全过程免费视频网址| 亚洲av日韩av永久在线观看| 国产亚洲综合网曝门系列| 猫咪社区免费资源在线观看| jizz免费观看| 在线亚洲午夜片AV大片| 国产亚洲综合久久系列| 免费观看大片毛片|