国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > HTML > 正文

ASP生成靜態(tài)Html文件的技術總結(jié)

2020-03-24 17:10:00
字體:
供稿:網(wǎng)友
%
filename= test.htm
if request( body ) then
set fso = Server.CreateObject( Scripting.FileSystemObject )
set htmlwrite = fso.CreateTextFile(server.mappath( filename ))
htmlwrite.write html head title request.form( title ) /title /head
htmlwrite.write body 輸出Title內(nèi)容: request.form( title ) br / 輸出Body內(nèi)容: request.form( body ) /body /html
htmlwrite.close
set fout=nothing
set fso=nothing
end if
%
form name= form method= post action=
input name= title value= Title size=26
br
textarea name= body Body /textarea
br
br
input type= submit name= Submit value= 生成html
/form 2、但是按照上面的方法生成html文件非常不方便,第二種方法就是利用模板技術,將模板中特殊代碼的值替換為從表單或是數(shù)據(jù)庫字段中接受過來的值,完成模板功能;將最終替換過的所有模板代碼生成HTML文件.這種技術采用得比較多,大部分的CMS都是使用這類方法.
template.htm //模板文件
html
head
title $title$ by aspid.cn /title
/head
body
$body$
/body
/html TestTemplate.asp // 生成Html
%
Dim fso,htmlwrite
Dim strTitle,strContent,strOut
// 創(chuàng)建文件系統(tǒng)對象
Set fso=Server.CreateObject( Scripting.FileSystemObject )
// 打開網(wǎng)頁模板文件,讀取模板內(nèi)容
Set htmlwrite=fso.OpenTextFile(Server.MapPath( Template.htm ))
strOut=f.ReadAll
htmlwrite.close strTitle= 生成的網(wǎng)頁標題
strContent= 生成的網(wǎng)頁內(nèi)容 // 用真實內(nèi)容替換模板中的標記
strOut=Replace(strOut, $title$ ,strTitle)
strOut=Replace(strOut, $body$ ,strContent) // 創(chuàng)建要生成的靜態(tài)頁
Set htmlwrite=fso.CreateTextFile(Server.MapPath( test.htm ),true) // 寫入網(wǎng)頁內(nèi)容
htmlwrite.WriteLine strOut
htmlwrite.close Response.Write 生成靜態(tài)頁成功! // 釋放文件系統(tǒng)對象
set htmlwrite=Nothing
set fso=Nothing
%html教程

鄭重聲明:本文版權歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 都兰县| 巴林左旗| 玛曲县| 东安县| 黄浦区| 延庆县| 清水河县| 景德镇市| 渝中区| 阿拉善右旗| 台中市| 许昌县| 永靖县| 井陉县| 铁岭县| 凤翔县| 水城县| 建阳市| 柳河县| 长汀县| 吴旗县| 千阳县| 广昌县| 酒泉市| 屏东县| 抚松县| 青海省| 平南县| 当涂县| 哈尔滨市| 河源市| 莆田市| 罗田县| 大连市| 黄山市| 秀山| 民和| 白水县| 北京市| 利辛县| 习水县|