asp实现静态页面简单剖析

实在是很简单的东西,只能给菜鸟看
模版文件Template.htm
<html>           
<head>           
<title>%TITLE%</title>           
</head>           
%CONTENT%            
</body>           
</html>  

生成静态页面文件 test.asp
<%            
Dim fso,f            
Dim strTitle,strContent,strOut            
'创建文件系统对象            
Set fso=Server.CreateObject("Scripting.FileSystemObject")            
           
'打开网页模板文件,读取模板内容            
Set f=fso.OpenTextFile(Server.MapPath("Template.htm"))            
strOut=f.ReadAll            
f.close            
           
strTitle="这是生成的网页标题"           
strContent="这是生成的网页的内容!"   
%>   

'用真实内容替换模板中的标记

很多系统生成的静态页面采用时间命名
可以如下:
<%            
fname = now()            
fname = replace(fname,"-","")            
fname = replace(fname," ","")            
fname = replace(fname,":","")            
fname = replace(fname,"PM","")            
fname = replace(fname,"AM","")            
fname = replace(fname,"上午","")            
fname = replace(fname,"下午","")            
fname = fname &amp; ".html"           
%>

这是最基本的东西,一个网站真的要全部生成静态页面,那要复杂的多!
<%    
strOut=Replace(strOut,"%TITLE%",strTitle)            
strOut=Replace(strOut,"%CONTENT%",strContent)            
           
'创建要生成的静态页            
Set f=fso.CreateTextFile(Server.MapPath("New.htm"),true)            
           
'写入网页内容            
f.WriteLine strOut            
f.close            
           
Response.Write "生成静态页成功!"           
           
'释放文件系统对象            
set f=Nothing           
set fso=Nothing           
%>
原文地址:https://www.cnblogs.com/fancing/p/1690818.html