asp 由動態網頁轉變為靜態網頁的實現代碼

來源:互聯網
上載者:User

具體代碼實現:
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 class="font_white"></span></div>
<!-- top開始 -->
<div><span class="font_white"></span></div>
<!-- top開始 -->
<div id="top">
<div class="left"></div>
<div class="right">
<div class="topuser">
<form class="formbox" action="login_click.asp" method="post" name="loginform" id="loginform" onSubmit="return checkform2()">
<div style="line-height: 22px;height: 22px;">使用者名稱:
<input name="uname" type="text" class="bot" id="uname" size="10" maxlength="10" /> 密 碼:
<input name="pwd" type="password" class="bot" id="pwd" size="10" maxlength="18"/><label></label>
<input type="submit" name="Submit" value="登 陸" /> <INPUT onClick="Javascript:window.location='/reg.asp';" type=button value="注 冊" name=Submit2></div>
</form>
</div>
<div class="bottomuser"><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>
<!-- top結束 -->
<!-- ad開始 -->
<div id="subject01"><a href="/info_jiamengzhengce.asp" target="_blank"><img src="/images/pic_948x160.jpg" alt="愛呀呀飾品加盟連鎖" width="948" height="218" border="0" /></a></div>
<!-- ad結束 -->
<div class="clear"></div>
<!-- top結束 -->
<!-- ad開始 -->
<!-- ad結束 -->
<div class="clear"></div>
<!-- 內容開始 -->
<div id="main">
<!-- 左邊開始 -->
<div class="left">
<div class="top" style="background:url(/images/fenlei_12_07.jpg);"></div>
<div class="middle">
<ul>
<script language="javascript" src="../../class.js"></script>
<li class="middle02"></li>
<li class="middle03">免費熱線:4006-888048<br>
<strong>大陸總部:</strong><br>
總機:0579-89960888 <br />
傳真:0579-85210995 <br>
<strong>香港總部:</strong><br>
電話:00852-36458129 <br>
傳真:00852-36458092 </li>
<li class="middle04"></li>
</ul>
</div>
<div class="bottom"></div>
<div class="leftnews"></div>
</div>
<!-- 左邊結束 -->
<div class="right">
<div class="righttop"></div>
<div class="rightmiddle">
<ul>
<li class="04"><table width="700" border="0" cellpadding="0" cellspacing="0" background="/images/title.jpg">
<tr>
<td width="104" height="32" align="center"><h1 style="color:#FFFFFF; font-size:14px; font-weight:bold; margin:0 auto; padding:0px;" >新聞中心</h1></td>
<td width="596" align="right">當前位置:<a href="/index.asp">首頁</a> - 新聞中心</td>
</tr>
</table>
<li class="02">
<h1 style="margin:10px; padding:2px; font-size:18px; text-align:center;">{title}</h1>
</li>
<li class="02" style="text-align:left;">{demo}</li>
</li>
</ul>
</div>
<div class="rightbottom"></div>
</div>
</div>
<!-- 內容結束 -->
<div class="clear"></div>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="/css/style_new.css" rel="stylesheet" type="text/css" />
<div class="clear"></div>
<!-- footer開始 -->
<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="/images/paizi_03.jpg" width="69" border="0" /></a></td>
<td width="869"><span class="font_space01"><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>
<!-- footer結束 -->
<span style="visibility: hidden;"><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) 複製代碼 代碼如下:<!--#include file="conn.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 style='color:#003333;' align='center'>"&rs("id")&"新聞產生HTML成功!</div>"
rs.movenext
loop
rs.close
response.write"<div style='color:#FF0000;' 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("..\templates\news_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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.