asp 由动态网页转变为静态网页的实现代码
asp 由动态网页转变为静态网页的实现代码
发布时间:2016-12-29 来源:查字典编辑
摘要:具体代码实现:1.模板文件(html)复制代码代码如下:{title}-新闻中心-哎呀呀饰品加盟连锁用户名:密码:首页|企业简介|产品展示|...

具体代码实现:

1.模板文件(html)

复制代码 代码如下:

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>{title} - 新闻中心 - 哎呀呀饰品加盟连锁</title>

<meta name="keywords" content="{metak},哎呀呀饰品店、哎呀呀加盟店、哎呀呀、哎呀呀加盟、哎呀呀饰品、哎呀呀饰品店、哎呀呀加盟店、哎呀呀连锁店、如何加盟哎呀呀" />

<meta name="description" content="{metad},(香港)哎呀呀饰品国际集团有限公司是一家经营饰品、日用品、化妆品、文具、玩具等为一体的公司,下设加工厂和连锁店两个利润中心。香港哎呀呀饰品公司欢迎您爱呀呀饰品加盟连锁店。" />

<link href="/css/style_new.css" rel="stylesheet" type="text/css" />

</head>

<body>

<div><span></span></div>

<>

<div><span></span></div>

<>

<div id="top">

<div></div>

<div>

<div>

<form action="login_click.asp" method="post" name="loginform" id="loginform" onSubmit="return checkform2()">

<div>用户名:

<input name="uname" type="text" id="uname" size="10" maxlength="10" /> 密 码:

<input name="pwd" type="password" id="pwd" size="10" maxlength="18"/><label></label>

<input type="submit" name="Submit" value="登 陆" /> <INPUT type=button value="注 册" name=Submit2></div>

</form>

</div>

<div><a href="/index.asp">首页</a> | <a href="/info_qiyejianjie.asp">企业简介</a> | <a href="/class/">产品展示</a> | <a href="/news_xinwenzhongxin.asp">新闻中心</a> | <a href="/info_jiamengzhengce.asp">经销政策</a> | <a href="/info_kaiyedali.asp">开业大礼</a> | <a href="/info_zhuangxiufangan.asp">装修方案</a> | <a href="/info_xingxiangzhanshi.asp">形象展示</a> | <a href="/info_jiamengliucheng.asp">合作流程</a> | <a href="/info_touziwenda.asp">投资问答</a> | <a href="/zaixianliuyan.asp">在线留言</a></div>

</div>

</div>

<>

<>

<div id="subject01"><a href="/info_jiamengzhengce.asp" target="_blank"><img src="http://www.jb51.netimages/pic_948x160.jpg" alt="爱呀呀饰品加盟连锁" width="948" height="218" border="0" /></a></div>

<>

<div></div>

<>

<>

<>

<div></div>

<>

<div id="main">

<>

<div>

<div></div>

<div>

<ul>

<script language="javascript" src="../../class.js"></script>

<li></li>

<li>免费热线:4006-888048<br>

<strong>大陆总部:</strong><br>

总机:0579-89960888 <br />

传真:0579-85210995 <br>

<strong>香港总部:</strong><br>

电话:00852-36458129 <br>

传真:00852-36458092 </li>

<li></li>

</ul>

</div>

<div></div>

<div></div>

</div>

<>

<div>

<div></div>

<div>

<ul>

<li><table width="700" border="0" cellpadding="0" cellspacing="0" background="/images/title.jpg">

<tr>

<td width="104" height="32" align="center"><h1 >新闻中心</h1></td>

<td width="596" align="right">当前位置:<a href="/index.asp">首页</a> - 新闻中心</td>

</tr>

</table>

<li>

<h1>{title}</h1>

</li>

<li>{demo}</li>

</li>

</ul>

</div>

<div></div>

</div>

</div>

<>

<div></div>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<link href="/css/style_new.css" rel="stylesheet" type="text/css" />

<div></div>

<>

<table cellspacing="0" cellpadding="0" width="948" align="center" border="0">

<tbody>

<tr>

<td valign="center" align="middle" width="79"><a href="/info_lianxiwomen.asp"><img height="66" alt="点击进入" src="http://www.jb51.netimages/paizi_03.jpg" width="69" border="0" /></a></td>

<td width="869"><span><a href="/info_qiyejianjie.asp">关于爱呀呀</a> │ <a href="/info_jiamengzhengce.asp">加盟政策</a> | <a href="/info_zhuangxiufangan.asp">装修方案</a> | <a href="/info_jiamengyoushi.asp">加盟优势</a> | <a href="/class/">产品展示</a>│<a href="/zaixianliuyan.asp">在线留言</a>│<a href="/info_lianxiwomen.asp">联系我们</a>│<a href="sitemap.html" target="_blank">网站地图</a></span><br />

大陆区地址:浙江省义乌市经济开发区石鱼路123号8栋(稠江中学旁)大陆区电话:0579-89960888 免费热线:4006-888048 <br />

</td>

</tr>

</tbody>

</table>

<>

<span><a href="http://www.51aiyaya.com" target="_blank"><strong>哎呀呀</strong></a>

<a href="http://www.51aiyaya.com" target="_blank">哎呀呀加盟</a>

<a href="http://www.51aiyaya.com" target="_blank">哎呀呀饰品</a> <script src="http://s23.cnzz.com/stat.php?id=1117055&web_id=1117055" language="JavaScript" charset="gb2312"></script></span>

</body>

</html>

2.处理的文件(asp)

复制代码 代码如下:

<>

<%Server.ScriptTimeOut=99999999%>

<%

dim action,id,news

Layout="news"

id=request.QueryString("id")

action=request.QueryString("action")

select case action

case "add"

%>

<%

'全部生成html

case "htmlall"

set rs=server.CreateObject("adodb.recordset")

Sql = "Select id from news order by id"

rs.open sql,conn,1,1

do while not rs.eof

FsoFile "news",rs("id")

response.write"<div align='center'>"&rs("id")&"新闻生成HTML成功!</div>"

rs.movenext

loop

rs.close

response.write"<div align='center'>全部新闻生成HTML成功!</div></br>"

end select

%>

<%

'生成中文html

Function FsoFile(Layout,ID)

Dim Fso,FilePath,FsoF,FsoH,FsoRs,CreateFilePath

FSOCreateDIR "..news" & ID & ""

CreateFilePath = "..news" & ID & "" 'HTML所在文件夹

FilePath=Server.Mappath(CreateFilePath) & "index.html" '定义生成html文件名

Set Fso=Server.CreateObject("Scripting.FileSystemObject")

Set FsoH=Fso.OpenTextFile(Server.Mappath("..templatesnews_show.html"),1,true) '读取模版

Content = FsoH.ReadAll

Set FsoRs = Conn.Execute("select * from news where id="&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

Set FsoRs=Nothing

set stm = server.createobject("ADODB.Stream")

stm.Charset = "gb2312" '定义编码

stm.Open

stm.WriteText content

stm.SaveToFile FilePath, 2

set stm = nothing

End Function

%>

<%

function FSOCreateDIR(LocalPath)

dim patharr,path_level,i,pathtmp,cpath,CreateDIR,FileObject

on error resume next

LocalPath = Server.MapPath(LocalPath)

LocalPath = replace(LocalPath,"","/")

set FileObject = server.createobject("Scripting.FileSystemObject")

patharr = split(LocalPath,"/")

path_level = ubound(patharr)

for i = 0 to path_level

if i=0 then pathtmp = patharr(0) & "/" else pathtmp = pathtmp & patharr(i) & "/"

cpath = left(pathtmp,len(pathtmp)-1)

if not FileObject.FolderExists(cpath) then FileObject.CreateFolder(cpath)

next

set FileObject = nothing

if err.number<>0 then

CreateDIR = false

err.Clear

else

CreateDIR = true

end if

end function

%>

3.在后台添加生成静态新闻链接

复制代码 代码如下:

<TD height=20 align="center"><a href="../admin_product/saveaddnews.asp?action=htmlall" target="ggdlab">生成新闻静态</a></TD>

来源于我的博客

http://blog.csdn.net/lingfeng179

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新ASP教程学习
热门ASP教程学习
编程开发子分类