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

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

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

    Andy Luo:
    1、在生成頁面后更新數據庫中鏈接地址,或做一個標記,使得主頁上各篇文章的鏈接地址指向靜態頁面。
    2、在第一次訪問文章時創建靜態頁面,或在服務器定時查詢新增紀錄並生成靜態頁面
    3、訪問主業時也可生成靜態網葉,通過查詢數據庫中一個記錄,獲取最新文章的錄入時間,比較並更新主業的靜態網葉

    轉自:http://blueline.hit.edu.cn/ccs/blogs/loveme/archive/2006/03/03/1030.aspx

    為了減輕服務器壓力,將原來的文章管理系統由JSP文件的從數據庫中取數據顯示改為由jsp生成靜態html文件后直接訪問html文件。下面是一個簡單的示例

    1.buildhtml.jsp

    <%@ page contentType="text/html; charset=gb2312" import="java.util.*,java.io.*"%>
    <%
    try{
     String title="This is Title";
     String content="This is Content Area";
     String editer="LaoMao";
     String filePath = "";
     filePath = request.getRealPath("/")+"test/template.htm";
     //out.print(filePath+"<br>");
     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);//建立文件輸出流
     byte tag_bytes[] = templateContent.getBytes();
     fileoutputstream.write(tag_bytes);
     fileoutputstream.close();
    }
    catch(Exception e){
     out.print(e.toString());
    }

    %>

    2. 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:###author###&nbsp;&nbsp;</td>
      </tr>
      <tr>
        <td>###content###
     </td>
     
      </tr>

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



    版權所有 羅明
    posted on 2006-03-05 22:05 羅明 閱讀(2643) 評論(3)  編輯  收藏 所屬分類: Server
    Comments
     
    主站蜘蛛池模板: 黄色网址大全免费| 国产无遮挡吃胸膜奶免费看视频 | 在线观看免费大黄网站| 日本免费人成黄页在线观看视频| 亚洲欧洲中文日韩av乱码| 国产亚洲美日韩AV中文字幕无码成人| 亚洲国产天堂久久综合网站 | 亚洲国产精品久久久久秋霞小 | 37pao成人国产永久免费视频| 女人18毛片免费观看| 亚洲av永久无码精品国产精品| 亚洲人成网男女大片在线播放| h片在线播放免费高清| 无码人妻一区二区三区免费| 亚洲精品国产精品乱码不99| 亚洲熟伦熟女专区hd高清| 99视频在线看观免费| 亚洲毛片av日韩av无码| 中文文字幕文字幕亚洲色| 久久www免费人成精品香蕉| 免费看美女被靠到爽| 亚洲美女视频网站| 免费无码作爱视频| 免费v片在线观看品善网| 亚洲日韩精品无码专区加勒比☆| 久久成人免费大片| 亚洲国产一二三精品无码| 青青免费在线视频| 免费大黄网站在线看| 亚洲精品无码专区在线| 国产精品视频免费一区二区| 精品亚洲成a人片在线观看 | 中文亚洲AV片在线观看不卡| 特级毛片aaaa免费观看| 亚洲欧洲自拍拍偷精品 美利坚| 色网站在线免费观看| 又粗又大又硬又爽的免费视频 | 亚洲一区二区三区在线观看精品中文| 国产免费MV大全视频网站| 亚洲免费无码在线| 日本黄色动图免费在线观看|