




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、ASP中生成靜態(tài)頁面技術(shù)作 者:漢南居士關(guān)鍵字:ASP技術(shù)應(yīng)用 % dim str function menu(id) set rs=server.CreateObject(adodb.recordset) sql=select * from menu where id1=&id& order by url,id rs.open sql,conn,1,1 str=str+chr(13) i=1 while not rs.eof ChildCount=conn.execute(select count(*) from menu where id1=&rs(id)(0) if ChildCount
2、=0 then if i=rs.recordcount then menutype=file1 else menutype=file end if menuname=&rs(menuname)& onmouseup= else if i=rs.recordcount then menutype=menu3 listtype=list1 onmouseup= onMouseUp=change1(a&rs(id)&,b&rs(id)&); else menutype=menu1 listtype=list onmouseup= onMouseUp=change2(a&rs(id)&,b&rs(id
3、)&); end if menuname=rs(menuname) end if str=str+&menuname&+chr(13) if ChildCount0 then str=str+chr(13) menu(rs(id) str=str+chr(13) end if rs.movenext i=i+1 wend str=str+chr(13) rs.close set rs=nothing end function menu(0) set fso=server.CreateObject(scripting.filesystemobject) set f1=fso.opentextfi
4、le(server.MapPath(demo.htm),2,true) f1.write(;) f1.write() f1.write() f1.write() f1.write(哈哈!這回速度超快了吧?) f1.write() f1.write() f1.write() f1.write() f1.write() f1.write() f1.write(提供最新下載管理) f1.write(str) f1.write() f1.write() f1.close set fso=nothing response.Redirect(demo.htm) %絕妙的a
5、sp生成靜態(tài)頁面 作 者:漢南居士關(guān)鍵字:ASP技術(shù)應(yīng)用隨著網(wǎng)站訪問量的加大,每次從數(shù)據(jù)庫讀取都是以效率作為代價(jià)的,很多用ACCESS作數(shù)據(jù)庫的更會(huì)深有體會(huì),靜態(tài)頁加在搜索時(shí),也會(huì)被優(yōu)先考慮?;ヂ?lián)網(wǎng)上流行的做法是將數(shù)據(jù)源代碼寫入數(shù)據(jù)庫再從數(shù)據(jù)庫讀取生成靜態(tài)面,這樣無形間就加大了數(shù)據(jù)庫。將現(xiàn)有的ASP頁直接生成靜態(tài)頁,將會(huì)節(jié)省很多。下面的例子是將、index.asp?id=1/index.asp?id=2/index.asp?id=3/這三個(gè)動(dòng)態(tài)頁面,分別生成ndex1.htm,index2.htm,index3.htm存在根目錄下面%dim strUrl,Item_Classid,id,Fil
6、eName,FilePath,Do_Url,Html_TempHtml_Temp=For i=1 To 3Html_Temp = Html_Temp&Item_Classid = iFileName = Index&Item_Classid&.htmFilePath = Server.MapPath(/)&FileNameHtml_Temp = Html_Temp&FilePath&Do_Url = http:/Do_Url = Do_Url&Request.ServerVariables(SERVER_NAME)&/main/index.aspDo_Url = Do_Url&?Item_Cl
7、assid=&Item_ClassidstrUrl = Do_Urldim objXmlHttpset objXmlHttp = Server.CreateObject(Microsoft.XMLHTTP)objXmlHttp.open GET,strUrl,falseobjXmlHttp.send()Dim binFileDatabinFileData = objXmlHttp.responseBodyDim objAdoStreamset objAdoStream = Server.CreateObject(ADODB.Stream)objAdoStream.Type = 1objAdoS
8、tream.Open()objAdoStream.Write(binFileData)objAdoStream.SaveToFile FilePath,2 objAdoStream.Close()NextHtml_Temp = Html_Temp&%Response.Write ( 成功生成文件: )Response.Write ( )Response.Write Html_Temp%-另一種方法-ASP生成靜態(tài)頁經(jīng)過我在網(wǎng)上的搜索,似乎要避免fso生成靜態(tài)頁的可能性不大,但是,我順便搜索了些生成靜態(tài)頁的教程希望大家用的著ASP生成靜態(tài)網(wǎng)頁的方法隨著網(wǎng)站訪問量的加大,每次從數(shù)據(jù)庫讀取都是以效率
9、作為代價(jià)的,很多用ACCESS作數(shù)據(jù)庫的更會(huì)深有體會(huì),靜態(tài)頁加在搜索時(shí),也會(huì)被優(yōu)先考慮。互聯(lián)網(wǎng)上流行的做法是將數(shù)據(jù)源代碼寫入數(shù)據(jù)庫再從數(shù)據(jù)庫讀取生成靜態(tài)面,這樣無形間就加大了數(shù)據(jù)庫。將現(xiàn)有的ASP頁直接生成靜態(tài)頁,將會(huì)節(jié)省很多。下面的例子是將、index.asp?id=1/index.asp?id=2/index.asp?id=3/這三個(gè)動(dòng)態(tài)頁面,分別生成ndex1.htm,index2.htm,index3.htm存在根目錄下面:%dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_TempHtml_Temp=For i=1 To
10、 3Html_Temp = Html_Temp&Item_Classid = iFileName = Index&Item_Classid&.htmFilePath = Server.MapPath(/)&FileNameHtml_Temp = Html_Temp&FilePath&Do_Url = http:/Do_Url = Do_Url&Request.ServerVariables(SERVER_NAME)&/main/index.aspDo_Url = Do_Url&?Item_Classid=&Item_ClassidstrUrl = Do_Urldim objXmlHttpset
11、 objXmlHttp = Server.CreateObject(Microsoft.XMLHTTP)objXmlHttp.open GET,strUrl,falseobjXmlHttp.send()Dim binFileDatabinFileData = objXmlHttp.responseBodyDim objAdoStreamset objAdoStream = Server.CreateObject(ADODB.Stream)objAdoStream.Type = 1objAdoStream.Open()objAdoStream.Write(binFileData)objAdoSt
12、ream.SaveToFile FilePath,2 objAdoStream.Close()NextHtml_Temp = Html_Temp&%Response.Write ( 成功生成文件: )Response.Write ( )Response.Write Html_Temp%非摸板生成靜態(tài)頁目前已經(jīng)有很多生成html的新聞系統(tǒng),但是都是用的模板,本函數(shù)實(shí)現(xiàn)把a(bǔ)sp頁面產(chǎn)生的html代碼保存成為一個(gè)html文件,這樣就沒有必要改動(dòng)原來的頁面就可以輕松完成一個(gè)生成html的新聞系統(tǒng)了。_由于代碼比較短,這里就不進(jìn)行注釋了%當(dāng)目標(biāo)頁面的包含文件即i nclude的頁面里邊存在respons
13、e.End()的時(shí)候本程序有問題注意:本文件一定要放在filename指向的文件的同一目錄下dim hughchiu_rtcodeFunction get_exe_code(filename)dim execodedim tmp_strDim re,re1,content,fso,f,aspStart,aspEnddim ms,mexecode = set fso=CreateObject(Scripting.FileSystemObject)set f=fso.OpenTextFile(server.mappath(filename)content=f.ReadAllf.closeset f
14、=nothingset fso=nothingset re = new regexpre.ignorecase = truere.global = truere.pattern = content = re.replace(content,)re.global = falsere.pattern = doset ms = re.execute(content)if ms.count0 thenset m = ms(0)tmp_str = get_exe_code(m.submatches(0)content = re.replace(content, tmp_str)elseexit doen
15、d ifloopset m = nothingset ms = nothingre.pattern=s*=aspEnd=1aspStart=inStr(aspEnd,content,aspEnd+1 execode = execode&vbcrlf& hughchiu_rtcode = hughchiu_rtcode&replace( replace(Mid(content,aspEnd,aspStart-aspEnd-2),), vbcrlf, &vbcrlf&)&vbcrlf aspEnd=inStr(aspStart,content,%)+2 tmp_str = Mid(content,
16、aspStart,aspEnd-aspStart-2) doset ms = re1.execute(tmp_str)if ms.count0 thenset m = ms(0)tmp_str = re1.replace(tmp_str, hughchiu_rtcode = hughchiu_rtcode&m.submatches(0)elseexit doend ifloop set m = nothing set ms = nothing execode = execode& re.replace(tmp_str,hughchiu_rtcode = hughchiu_rtcode&) as
17、pStart=inStr(aspEnd,content,%)+2loopset re1 = nothingset re=nothingexecode = execode&vbcrlf& hughchiu_rtcode = hughchiu_rtcode&replace( replace(Mid(content,aspEnd), , ), vbcrlf, &vbcrlf& )&vbcrlfget_exe_code = End Functionfunction asp2html(filename)dim codecode = replace( replace( replace( get_exe_c
18、ode(filename), hughchiu_rtcode = hughchiu_rtcode&vbcrlf, ), , )response.Write(code)execute(code)response.Write( hughchiu_rtcode )asp2html = hughchiu_rtcodeend function%使用范例:set fso=CreateObject(Scripting.FileSystemObject)set f=fso.CreateTextFile( server.mappath( youpage.htm ), true )f.WriteLine( asp
19、2html(youpage.asp) )f.closeset f = nothingset fso = nothing 來源:互聯(lián)網(wǎng)閱讀:494 次日期:2006-6-19一個(gè)用asp生成html的新方法 作 者:漢南居士關(guān)鍵字:ASP技術(shù)應(yīng)用目前已經(jīng)有很多生成html的新聞系統(tǒng),但是都是用的模板,本函數(shù)實(shí)現(xiàn)把a(bǔ)sp頁面產(chǎn)生的html代碼保存成為一個(gè)html文件,這樣就沒有必要改動(dòng)原來的頁面就可以輕松完成一個(gè)生成html的新聞系統(tǒng)了。_ 由于代碼比較短,這里就不進(jìn)行注釋了%當(dāng)目標(biāo)頁面的包含文件即#include的頁面里邊存在response.end()的時(shí)候本程序有問題注意:本文件一定要放在f
20、ilename指向的文件的同一目錄下dim hughchiu_rtcodefunction get_exe_code(filename) dim execode dim tmp_str dim re,re1,content,fso,f,aspstart,aspend dim ms,m execode = set fso=createobject(scripting.filesystemobject) set f=fso.opentextfile(server.mappath(filename) content=f.readall f.close set f=nothing set fso=no
21、thing set re = new regexp re.ignorecase = true re.global = true re.pattern = content = re.replace(content,) re.global = false re.pattern = do set ms = re.execute(content)if ms.count0 thenset m = ms(0)tmp_str = get_exe_code(m.submatches(0)content = re.replace(content, tmp_str)elseexit doend if loop s
22、et m = nothing set ms = nothing re.pattern=s*= aspend=1 aspstart=instr(aspend,content,aspend+1 execode = execode!amp;vbcrlf!amp; hughchiu_rtcode = hughchiu_rtcode!amp;!amp;replace( replace(mid(content,aspend,aspstart-aspend-2),), vbcrlf, !amp;vbcrlf!amp;)!amp;!amp;vbcrlf aspend=instr(aspstart,conten
23、t,%)+2 tmp_str = mid(content,aspstart,aspend-aspstart-2) doset ms = re1.execute(tmp_str)if ms.count0 thenset m = ms(0)tmp_str = re1.replace(tmp_str, hughchiu_rtcode = hughchiu_rtcode!amp;!amp;m.submatches(0)elseexit doend ifloop set m = nothing set ms = nothing execode = execode!amp; re.replace(tmp_str,hughchiu_rtcode = hughchiu_rtcode!amp;) aspst
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年濟(jì)源職業(yè)技術(shù)學(xué)院單招職業(yè)技能測試題庫及答案一套
- 2024四川自貢市國投融資擔(dān)保有限責(zé)任公司員工招聘2人筆試參考題庫附帶答案詳解
- 2024四川綿陽科技城科新醫(yī)療發(fā)展有限公司招聘投資與戰(zhàn)略管理崗位測試筆試參考題庫附帶答案詳解
- 2024云南建水供銷集團(tuán)有限公司招聘4人筆試參考題庫附帶答案詳解
- 第15課《驛路梨花》教學(xué)設(shè)計(jì) 2023-2024學(xué)年統(tǒng)編版語文七年級(jí)下冊
- 2024下半年安徽交控集團(tuán)聯(lián)網(wǎng)公司職員招聘3人筆試參考題庫附帶答案詳解
- 2025年廣東生態(tài)工程職業(yè)學(xué)院單招職業(yè)技能測試題庫完整
- 2025年貴州電子科技職業(yè)學(xué)院單招職業(yè)傾向性測試題庫學(xué)生專用
- 2025年廣東省湛江市單招職業(yè)適應(yīng)性測試題庫學(xué)生專用
- 2025年吉林職業(yè)技術(shù)學(xué)院單招職業(yè)傾向性測試題庫新版
- 重大緊急情況的報(bào)告模板
- 二人合伙開寵物店協(xié)議書(5篇)
- 十字相乘法解一元二次方程專題練習(xí)
- 汽車維修競標(biāo)報(bào)價(jià)表格范本
- 2023年3月普通高等學(xué)校招生全國統(tǒng)一考試英語聽力天津卷A(聽力音頻+試題+答案+聽力原文)
- 坐標(biāo)紙(A4紙直接打印就可用)
- OGC網(wǎng)絡(luò)服務(wù)公共執(zhí)行規(guī)范課件
- 抖音博主在線寫電腦配置同款表格
- 中央空調(diào)基礎(chǔ)知識(shí)及發(fā)展史
- 品質(zhì)基礎(chǔ)及品質(zhì)意識(shí)培訓(xùn)資料
- 電力工程竣工驗(yàn)收?qǐng)?bào)告
評(píng)論
0/150
提交評(píng)論