zl程序教程

您现在的位置是:首页 >  移动开发

当前栏目

asp由动态网页转变为静态网页的实现代码

ASP网页静态代码 实现 动态 转变
2023-06-13 09:14:11 时间
具体代码实现:
1.模板文件(html)
复制代码代码如下:

<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<title>{title}-新闻中心-哎呀呀饰品加盟连锁</title>
<metaname="keywords"content="{metak},哎呀呀饰品店、哎呀呀加盟店、哎呀呀、哎呀呀加盟、哎呀呀饰品、哎呀呀饰品店、哎呀呀加盟店、哎呀呀连锁店、如何加盟哎呀呀"/>
<metaname="description"content="{metad},(香港)哎呀呀饰品国际集团有限公司是一家经营饰品、日用品、化妆品、文具、玩具等为一体的公司,下设加工厂和连锁店两个利润中心。香港哎呀呀饰品公司欢迎您爱呀呀饰品加盟连锁店。"/>
<linkhref="/css/style_new.css"rel="stylesheet"type="text/css"/>
</head>
<body>
<div><spanclass="font_white"></span></div>
<!--top开始-->
<div><spanclass="font_white"></span></div>
<!--top开始-->
<divid="top">
<divclass="left"></div>
<divclass="right">
<divclass="topuser">
<formclass="formbox"action="login_click.asp"method="post"name="loginform"id="loginform"onSubmit="returncheckform2()">
<divstyle="line-height:22px;height:22px;">用户名:
<inputname="uname"type="text"class="bot"id="uname"size="10"maxlength="10"/>密码:
<inputname="pwd"type="password"class="bot"id="pwd"size="10"maxlength="18"/><label></label>
<inputtype="submit"name="Submit"value="登陆"/><INPUTonClick="Javascript:window.location="/reg.asp";"type=buttonvalue="注册"name=Submit2></div>
</form>
</div>
<divclass="bottomuser"><ahref="/index.asp">首页</a>|<ahref="/info_qiyejianjie.asp">企业简介</a>|<ahref="/class/">产品展示</a>|<ahref="/news_xinwenzhongxin.asp">新闻中心</a>|<ahref="/info_jiamengzhengce.asp">经销政策</a>|<ahref="/info_kaiyedali.asp">开业大礼</a>|<ahref="/info_zhuangxiufangan.asp">装修方案</a>|<ahref="/info_xingxiangzhanshi.asp">形象展示</a>|<ahref="/info_jiamengliucheng.asp">合作流程</a>|<ahref="/info_touziwenda.asp">投资问答</a>|<ahref="/zaixianliuyan.asp">在线留言</a></div>
</div>
</div>
<!--top结束-->
<!--ad开始-->
<divid="subject01"><ahref="/info_jiamengzhengce.asp"target="_blank"><imgsrc="/images/pic_948x160.jpg"alt="爱呀呀饰品加盟连锁"width="948"height="218"border="0"/></a></div>
<!--ad结束-->
<divclass="clear"></div>
<!--top结束-->
<!--ad开始-->
<!--ad结束-->
<divclass="clear"></div>
<!--内容开始-->
<divid="main">
<!--左边开始-->
<divclass="left">
<divclass="top"style="background:url(/images/fenlei_12_07.jpg);"></div>
<divclass="middle">
<ul>
<scriptlanguage="javascript"src="../../class.js"></script>
<liclass="middle02"></li>
<liclass="middle03">免费热线:4006-888048<br>
<strong>大陆总部:</strong><br>
总机:0579-89960888<br/>
传真:0579-85210995<br>
<strong>香港总部:</strong><br>
电话:00852-36458129<br>
传真:00852-36458092</li>
<liclass="middle04"></li>
</ul>
</div>
<divclass="bottom"></div>
<divclass="leftnews"></div>
</div>
<!--左边结束-->
<divclass="right">
<divclass="righttop"></div>
<divclass="rightmiddle">
<ul>
<liclass="04"><tablewidth="700"border="0"cellpadding="0"cellspacing="0"background="/images/title.jpg">
<tr>
<tdwidth="104"height="32"align="center"><h1style="color:#FFFFFF;font-size:14px;font-weight:bold;margin:0auto;padding:0px;">新闻中心</h1></td>
<tdwidth="596"align="right">当前位置:<ahref="/index.asp">首页</a>-新闻中心</td>
</tr>
</table>
<liclass="02">
<h1style="margin:10px;padding:2px;font-size:18px;text-align:center;">{title}</h1>
</li>
<liclass="02"style="text-align:left;">{demo}</li>
</li>
</ul>
</div>
<divclass="rightbottom"></div>
</div>
</div>
<!--内容结束-->
<divclass="clear"></div>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
<linkhref="/css/style_new.css"rel="stylesheet"type="text/css"/>
<divclass="clear"></div>
<!--footer开始-->
<tablecellspacing="0"cellpadding="0"width="948"align="center"border="0">
<tbody>
<tr>
<tdvalign="center"align="middle"width="79"><ahref="/info_lianxiwomen.asp"><imgheight="66"alt="点击进入"src="/images/paizi_03.jpg"width="69"border="0"/></a></td>
<tdwidth="869"><spanclass="font_space01"><ahref="/info_qiyejianjie.asp">关于爱呀呀</a>│<ahref="/info_jiamengzhengce.asp">加盟政策</a>|<ahref="/info_zhuangxiufangan.asp">装修方案</a>|<ahref="/info_jiamengyoushi.asp">加盟优势</a>|<ahref="/class/">产品展示</a>│<ahref="/zaixianliuyan.asp">在线留言</a>│<ahref="/info_lianxiwomen.asp">联系我们</a>│<ahref="sitemap.html"target="_blank">网站地图</a></span><br/>
大陆区地址:浙江省义乌市经济开发区石鱼路123号8栋(稠江中学旁) 大陆区电话:0579-89960888免费热线:4006-888048<br/>
</td>
</tr>
</tbody>
</table>
<!--footer结束-->
<spanstyle="visibility:hidden;"><ahref="http://www.51aiyaya.com"target="_blank"><strong>哎呀呀</strong></a>
<ahref="http://www.51aiyaya.com"target="_blank">哎呀呀加盟</a>
<ahref="http://www.51aiyaya.com"target="_blank">哎呀呀饰品</a><scriptsrc="http://s23.cnzz.com/stat.php?id=1117055&web_id=1117055"language="JavaScript"charset="gb2312"></script></span>
</body>
</html>

2.处理的文件(asp)
复制代码代码如下:

<!--#includefile="conn.asp"-->
<%Server.ScriptTimeOut=99999999%>
<%
dimaction,id,news
Layout="news"
id=request.QueryString("id")
action=request.QueryString("action")
selectcaseaction
case"add"
%>
<%
"全部生成html
case"htmlall"
setrs=server.CreateObject("adodb.recordset")
Sql="Selectidfromnewsorderbyid"
rs.opensql,conn,1,1
dowhilenotrs.eof
FsoFile"news",rs("id")
response.write"<divstyle="color:#003333;"align="center">"&rs("id")&"新闻生成HTML成功!</div>"
rs.movenext
loop
rs.close
response.write"<divstyle="color:#FF0000;"align="center">全部新闻生成HTML成功!</div></br>"
endselect
%>
<%
"生成中文html
FunctionFsoFile(Layout,ID)
DimFso,FilePath,FsoF,FsoH,FsoRs,CreateFilePath
FSOCreateDIR"..\news\"&ID&""
CreateFilePath="..\news\"&ID&"""HTML所在文件夹
FilePath=Server.Mappath(CreateFilePath)&"\index.html""定义生成html文件名
SetFso=Server.CreateObject("Scripting.FileSystemObject")
SetFsoH=Fso.OpenTextFile(Server.Mappath("..\templates\news_show.html"),1,true)"读取模版
Content=FsoH.ReadAll
SetFsoRs=Conn.Execute("select*fromnewswhereid="&id)
title=FsoRs("title")
demo=FsoRs("demo")
Content=Replace(Content,"{id}",FsoRs("id"))
Content=Replace(Content,"{title}",FsoRs("title"))
Content=Replace(Content,"{demo}",FsoRs("demo"))
Content=Replace(Content,"{webname}",webname)
Content=Replace(Content,"{icp}",icp)
Content=Replace(Content,"{dianhua}",dianhua)
Content=Replace(Content,"{dizhi}",dizhi)
Content=Replace(Content,"{qq}",qq)
Content=Replace(Content,"{alibaba}",alibaba)
Content=Replace(Content,"{tongji}",tongji)
FsoRs.Close
SetFsoRs=Nothing
setstm=server.createobject("ADODB.Stream")
stm.Charset="gb2312""定义编码
stm.Open
stm.WriteTextcontent
stm.SaveToFileFilePath,2
setstm=nothing
EndFunction
%>
<%
functionFSOCreateDIR(LocalPath)
dimpatharr,path_level,i,pathtmp,cpath,CreateDIR,FileObject
onerrorresumenext
LocalPath=Server.MapPath(LocalPath)
LocalPath=replace(LocalPath,"\","/")
setFileObject=server.createobject("Scripting.FileSystemObject")
patharr=split(LocalPath,"/")
path_level=ubound(patharr)
fori=0topath_level
ifi=0thenpathtmp=patharr(0)&"/"elsepathtmp=pathtmp&patharr(i)&"/"
cpath=left(pathtmp,len(pathtmp)-1)
ifnotFileObject.FolderExists(cpath)thenFileObject.CreateFolder(cpath)
next
setFileObject=nothing
iferr.number<>0then
CreateDIR=false
err.Clear
else
CreateDIR=true
endif
endfunction
%>

3.在后台添加生成静态新闻链接
复制代码代码如下:
<TDheight=20align="center"><ahref="../admin_product/saveaddnews.asp?action=htmlall"target="ggdlab">生成新闻静态</a></TD>

来源于我的博客
http://blog.csdn.net/lingfeng179