以前在网上看一些新闻发布网站,总是看到除了主页是动态的页面外,其他子页的链接都是静态。
采用的是HTML静态页面生成技术。
我所知的一共有三种方法。但我所了解只有两种。还是用代码说话。。。
//第一种生成方式。
<%
Function CreatHtml(HtmlName,HtmlTitile,HtmlContent)'参数为相对路径
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set fileout = objFSO.CreateTextFile(server.mappath(HtmlName), True)
fileout.WriteLine("<html><head><title>"+HtmlTitile+"</title></head>")
fileout.WriteLine("<html><head><title>"+HtmlContent+"</title></head>")
fileout.Close
Set objFSO = nothing
End function
%>
<%
=CreatHtml("ddd.html","你好吗?","呵呵")
%>
//第二种方式,采用模板页。要先创个模板页,在里面某处在插入内容处进行标记。
//生成HTML代码
生成的ASP:
<%
dim t,fso
dim strTitle,strContent,strOut
set fso=Server.CreateObject("Scripting.FileSystemObject")
set t=fso.OpenTextFile(server.MapPath("template.htm"),1,false)
strOut=t.ReadAll
strTitle="生成的网页标题"
strContent="生成的网页内容"
strOut=Replace(strOut,"$title$",strTitle)
strOut=Replace(strOut,"$body$",strContent)
Set htmlwrite=fso.CreateTextFile(Server.MapPath("strOut.htm"),true)
htmlwrite.close
t.close
%>