| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1658 人关注过本帖
标题:ASP生成静态Html文件
只看楼主 加入收藏
treadwind
Rank: 2
等 级:论坛游民
帖 子:24
专家分:10
注 册:2005-10-15
收藏
 问题点数:0 回复次数:14 
ASP生成静态Html文件
怎么实现ASP页面生成HTML文件呢?网上找来资料没有看明白。
首页生成简单,但是内页,怎么实现呢?问题如下:

内页:Show.asp?id=124 这样的格式,怎么实现HTML,又怎么样跟首页关联起来呢??
搜索更多相关主题的帖子: ASP 静态 Html 文件 
2008-06-07 16:49
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
帮你顶,我也很想系统的学习下,就是找不到全面详细的资料!!!
2008-06-08 09:25
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
最简单的就是根据模板替换,用fso或者其他组件写入文件。

如果你不理解,完全可以下一个现成的CMS,看源代码嘛
2008-06-08 15:30
smhsmh
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-6-8
收藏
得分:0 
Filesystemobject生成HTML
变量 = 动态内容
Set Fso = Server.CreateObject("ScriptIng.FileSystemObject")
Set Fil = Fso.OpenTextFile("生成的目标文件",2,True)
Fil.Write 网页基本格式+变量
Set Fso = Nothing
2008-06-08 20:36
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
[bo][un]multiple1902[/un] 在 2008-6-8 15:30 的发言:[/bo]

最简单的就是根据模板替换,用fso或者其他组件写入文件。

如果你不理解,完全可以下一个现成的CMS,看源代码嘛



版主能不能麻烦找个典型的cms下载链接,好让我们事半功倍!!
2008-06-09 11:04
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
收藏
得分:0 
'-----生成分类(排序)代码,应用于调用-----------------------------
Function Makebook(Classid,Str,cont)

Select Case Str
 Case "0"
  sString = "默认排列"
  sHref   = ""
  oRderby = "updatetime"
 Case "1"
  sString = "总点击榜"
  sHref   = Book_Chits&"/"
  oRderby = "Chits"
 Case "2"
  sString = "月点击榜"
  sHref   = Book_Mhits&"/"
  oRderby = "Mhits"
 Case "3"
  sString = "周点击榜"
  sHref   = Book_Whits&"/"
  oRderby = "Whits"
 Case "4"
  sString = "总推荐榜"
  sHref   = Book_Crecs&"/"
  oRderby = "Crecs"
 Case "5"
  sString = "月推荐榜"
  sHref   = Book_Mrecs&"/"
  oRderby = "Mrecs"
 Case "6"
  sString = "周推荐榜"
  sHref   = Book_Wrecs&"/"
  oRderby = "Wrecs"
 Case "7"
  sString = "总收藏榜"
  sHref   = Book_Collects&"/"
  oRderby = "Collects"
End Select

If Cont = "0" Then
  Class_href = List_over
  oHref      = "完成作品"
Else
  Class_href = Class_more
  oHref      = "全部作品"
End If

If Classid = "0" Then
  cHref    = ""
Else
  cHref    = readtype(Classid,"Classname","List_class")&"-"
End If

If Classid = "0" And Cont = "0" Then
Cardnumber = conn.execute("select count(*) as recount from [List_book] where Islock=0 and Iscont=0")("recount")
ElseIf Classid <> "0" And Cont = "0" Then
Cardnumber = conn.execute("select count(*) as recount from [List_book] where Islock=0 and Classid="&Classid&" and Iscont=0")("recount")
ElseIf Classid = "0" And Cont = "1" Then
Cardnumber = conn.execute("select count(*) as recount from [List_book] where Islock=0")("recount")
ElseIf Classid <> "0" And Cont = "1" Then
Cardnumber = conn.execute("select count(*) as recount from [List_book] where Islock=0 and Classid="&Classid&"")("recount")
End If
sPageSize = Pagesizes
If Cardnumber mod sPageSize > 0 Then
sPgnum = Cint(Fix(Cardnumber/sPageSize) + 1)
Else
sPgnum = Cint(Cardnumber/sPageSize)
End If
If sPgnum > 0 Then
If sPage="" Or sPage<1 Then sPage = 1
If sPage > sPgnum Then sPage = sPgnum
For sPage = 1 To sPgnum
sPagecount = sPageSize*(sPage-1)
Set rs=Server.CreateObject("ADODB.Recordset")
If Classid = "0" And Cont = "0" Then
sql="select top "&sPageSize&" id,classid,bookname,writer,updatetime,Iscont from [List_book] where Islock=0 and Iscont=0 and not id in (select top "&sPagecount&" id from [List_book] where Islock=0 and Iscont=0 order by "&oRderby&" desc) order by "&oRderby&" desc"
ElseIf Classid <> "0" And Cont = "0" Then
sql="select top "&sPageSize&" id,classid,bookname,writer,updatetime,Iscont from [List_book] where Islock=0 and Classid="&Classid&" and Iscont=0 and not id in (select top "&sPagecount&" id from [List_book] where Islock=0 and Classid="&Classid&" and Iscont=0 order by "&oRderby&" desc) order by "&oRderby&" desc"
ElseIf Classid = "0" And Cont = "1" Then
sql="select top "&sPageSize&" id,classid,bookname,writer,updatetime,Iscont from [List_book] where Islock=0 and not id in (select top "&sPagecount&" id from [List_book] where Islock=0 order by "&oRderby&" desc) order by "&oRderby&" desc"
ElseIf Classid <> "0" And Cont = "1" Then
sql="select top "&sPageSize&" id,classid,bookname,writer,updatetime,Iscont from [List_book] where Islock=0 and Classid="&Classid&" and not id in (select top "&sPagecount&" id from [List_book] where Islock=0 and Classid="&Classid&" order by "&oRderby&" desc) order by "&oRderby&" desc"
End If
rs.open sql,conn,1,1
Pager = Makepage(cardnumber,sPage,FrontPage,AllPage,sPgnum)
Content = ""
do while not rs.eof
id=rs("id")
classname=readtype(rs("Classid"),"classname","List_class")
bookname=rs("bookname")
writer=rs("writer")
updatetime=rs("updatetime")

Set rs1=Server.CreateObject("ADODB.Recordset")
sql="select id,viewname from [List_view] where bookid="&id&" and Islock=0 order by id desc"
rs1.open sql,conn,1,1
If not rs1.eof Then
viewid=rs1("id")
viewname=rs1("viewname")
End If
rs1.close:set rs1=nothing

Content = Content & "<ul>" & Chr(13)
If Str = "" Then
Content = Content & "<li class=""l1"">[<a href="""&Class_href&rs("Classid")&"/1/"">"&classname&"</a>]</li>" & Chr(13)
Else
Content = Content & "<li class=""l1"">[<a href="""&Class_href&sHref&rs("Classid")&"/1/"">"&classname&"</a>]</li>" & Chr(13)

End If
Content = Content & "<li class=""l2""><a href="""&view_read&rs("Classid")&"/"&id&"/"">"&bookname&"</a></li>" & Chr(13)
Content = Content & "<li class=""l3""><a href="""&view_html&rs("Classid")&"/"&id&"/"&viewid&"/"">"&viewname&"</a></li>" & Chr(13)
Content = Content & "<li class=""l4""> "&Right(Year(updatetime),2)&"-"&Month(updatetime)&"-"&Day(updatetime)&"</li>" & Chr(13)
Content = Content & "<li class=""l5"">"&writer&"</li>" & Chr(13)
Content = Content & "<li class=""l6"">完成</li>" & Chr(13)
Content = Content & "</ul>" & Chr(13)

rs.movenext
loop

Header = FSOFileRead("/Model/head.htm")
Bottom = FSOFileRead("/Model/Bottom.htm")
Template = FSOFileRead("/Model/class.htm")

Template = Replace(Template,"{$Header$}",Header)
If Classid = "0" and Cont = "0" Then
Template = Replace(Template,"{$classname$}","全本小说")
ElseIf Classid = "0" and Cont = "1" Then
Template = Replace(Template,"{$classname$}","全部书籍")
Else
Template = Replace(Template,"{$classname$}",classname)
End If
Template = Replace(Template,"{$bottom$}",Bottom)
Template = Replace(Template,"{$Content$}",Content)
Template = Replace(Template,"{$Inturn$}",Maketurn(Classid,Class_href))
Template = Replace(Template,"{$Page$}",Pager)
Template = Replace(Template,"{$New$}",Newadd("12"))
Template = Replace(Template,"{$Rec$}",Classhits(Classid,"12"))
Template = Replace(Template,"{$Hit$}",Makerank("Dhits","12"))
Template = Replace(Template,"{$site_title$}",site_title)
Template = Replace(Template,"{$site$}",site)

Call createhtml(Class_href&sHref&Classid&"/"&sPage&"/"&web_Html,Template)
Response.Write "生成分类【"&oHref&"-"&cHref&sString&"】第"&sPage&"页,地址:<a href="""&Class_href&sHref&Classid&"/"&sPage&"/"" target=""_blank"">"&Class_href&sHref&Classid&"/"&sPage&"/</a><br />"

rs.close:set rs=nothing
Next
Response.Flush()
Response.Clear()
End If

End Function
2008-06-09 12:59
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
收藏
得分:0 
'----------------FSO操作------------------------------
'*****************************************************************
'     读取文件
'*****************************************************************
Function FSOFileRead(Template_Name)
Dim objFSO,objCountFile,FiletempData
Set objFSO = Server.CreateObject(FSOstr)
Set objCountFile = objFSO.OpenTextFile(Server.MapPath(Template_Name),1,True)
If objCountFile.AtEndOfStream = false Then FSOFileRead = objCountFile.ReadAll
objCountFile.Close
Set objCountFile=Nothing
Set objFSO = Nothing
End Function

'*****************************************************************
'     读取文件夹创建时间,大于一个小时则删除
'*****************************************************************
Function FolderTime(path)  
If IsFolder(path)=True Then
    Dim fso
    Set fso = CreateObject(FSOstr)
    set objfolder = fso.getfolder(server.mappath(path))
    for each objsubfolder in objfolder.subfolders
    If datediff("S",fso.getfolder(server.mappath(path&objsubfolder.name)).datecreated,Now())>sTime Then
    fso.DeleteFolder(server.mappath(path&objsubfolder.name))
    End If
    next
    set objfolder = Nothing
    set fso = Nothing
End If
End Function

'*****************************************************************
'     创建文件夹
'*****************************************************************
Function CreateFolder(fldr)
on error resume next
    Dim fso,f,GetFold,path
    CreateFolder = False
    Set fso = CreateObject(FSOstr)
    GetFold=split(fldr,"/")
    For e=0 to Ubound(GetFold)-1
        path=""
        for ee=0 to e
            path=path&GetFold(ee)&"/"
        next
        If IsFolder(path)=false then fso.CreateFolder(Server.MapPath(path))
    Next
    Set fso=nothing
    CreateFolder = True
End Function

'*****************************************************************
'     创建文件
'*****************************************************************
Function createhtml(path,str)
Dim fso,fout,fldr,GetFold
GetFold=split(path,"/")
For e=0 to Ubound(GetFold)-1
    fldr=""
    for ee=0 to e
        fldr=fldr&GetFold(ee)&"/"
    next
    If IsFolder(fldr)=false then CreateFolder fldr
Next
Set fso = Server.CreateObject(FSOstr)
Set fout = fso.CreateTextFile(server.mappath(path))
fout.Write str
fout.close
set fso = nothing
End Function

'*****************************************************************
'     删除文件夹
'*****************************************************************
Function DelFolder(path)
If IsFolder(path)=True Then
    Dim fso
    Set fso = CreateObject(FSOstr)
    fso.DeleteFolder(server.mappath(path))
    set fso = Nothing
End If
End Function


'*****************************************************************
'     删除文件
'*****************************************************************
Function delfile(path)
If IsExists(path)=True Then
    Dim fso
    set fso = server.CreateObject(FSOstr)
    fso.DeleteFile(server.mappath(path))
    set fso = nothing
End If
End Function
 
'*****************************************************************
'     检测文件是否存在
'*****************************************************************
Function IsExists(filespec)
    Dim fso
    Set fso = CreateObject(FSOstr)
    If (fso.FileExists(server.MapPath(filespec))) Then
    IsExists = True
    Else
    IsExists = False
    End If
    Set fso=nothing
End Function

'*****************************************************************
'     检测文件夹是否存在
'*****************************************************************
Function IsFolder(Folder)
    Dim fso
    Set fso = CreateObject(FSOstr)
    If FSO.FolderExists(server.MapPath(Folder)) Then  
    IsFolder = True
    Else
    IsFolder = False
    End If
    Set fso=nothing
End Function
2008-06-09 13:00
zhangyao3287
Rank: 2
来 自:黑龙江省
等 级:论坛游民
威 望:2
帖 子:173
专家分:51
注 册:2008-5-25
收藏
得分:0 
代码写的比较乱,呵呵,讲究看一下吧
2008-06-09 13:01
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
收藏
得分:0 
[bo][un]xinzheng[/un] 在 2008-6-9 11:04 的发言:[/bo]




版主能不能麻烦找个典型的cms下载链接,好让我们事半功倍!!

Powereasy SiteWeaver

注意里面的powereasy.fso.asp
2008-06-09 13:05
xinzheng
Rank: 1
等 级:新手上路
帖 子:193
专家分:0
注 册:2007-7-22
收藏
得分:0 
[bo][un]multiple1902[/un] 在 2008-6-9 13:05 的发言:[/bo]


Powereasy SiteWeaver

注意里面的powereasy.fso.asp


下载了,看看,不知道能不能懂
2008-06-09 14:10
快速回复:ASP生成静态Html文件
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042185 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved