求助asp wap 一个简单的程序

显示一个列表内容从a.txt读取a.txt格式:XXXXXwww.abc.comXXXXwww.cde.com输出XXX并链接后面的链接编码要可以显示中文字符最好实现分页... 显示一个列表 内容从a.txt 读取
a.txt 格式:
XXXXX www.abc.com
XXXX www.cde.com
输出 XXX 并链接 后面的链接
编码要可以显示中文字符
最好实现分页功能
展开
 我来答
zxlxxl
2011-01-09 · TA获得超过630个赞
知道小有建树答主
回答量:928
采纳率:0%
帮助的人:482万
展开全部
把下面代码保存成asp文件,并在同一目录放置一个a.txt
已测试

<%
dim fileStr,strTmp,aStr,pageNo

pageNo=cint(request.querystring("page"))
fileStr="a.txt"
strTmp=fsofileread(fileStr)
aStr=split(strTmp,vbcrlf)

if pageNo=0 then
viewPage 1,ubound(aStr)
else
viewPage pageNo,ubound(aStr)
end if

'*******************************************************************
'显示页面跳转列表
dim strPage
dim pgeNo

if int(ubound(aStr)/20)=ubound(aStr)/20 then
pgeNo=ubound(aStr)/20
else
pgeNo=ubound(aStr)/20+1
end if

for i=1 to pgeNo
strPage=strPage & "<a href='a.asp?page=" & i & "'>第" & i & "页</a> "
next
response.write strPage
'*******************************************************************

'显示第pNo页,每页20行pCount是总行数
sub viewPage(pNo,pCount)
dim PageNo
PageNo=pNo
for i=(PageNo-1)*20 to (PageNo-1)*20+19
if i>pCount-1 then exit for
Response.write "<a href='" & split(aStr(i)," ")(1) & "'>" & split(aStr(i)," ")(0) & "</a><p>"
next
end sub

'读取文件
function fsofileread(filename)
dim objfso,objcountfile,filetempdata
set objfso = server.createobject("scripting.filesystemobject")
set objcountfile = objfso.opentextfile(server.mappath(filename),1,true)
fsofileread = objcountfile.readall
objcountfile.close
set objcountfile=nothing
set objfso = nothing
end function

%>
度老虎
2011-01-09 · TA获得超过1546个赞
知道大有可为答主
回答量:1661
采纳率:100%
帮助的人:2328万
展开全部
以下程序测试通过:
<%
Option Explicit
Response.Buffer = True
'If Request.ServerVariables("HTTP_x-up-calling-line-id")<>"" Then
Response.ContentType = "text/vnd.wap.wml; charset=UTF-8"
'End If

Dim strHTML
Dim objFSO
Dim myFile
Dim arrLink,myLine,strWord,strUrl
Dim MaxPerPage,CurrentPage,PageCounts
Dim LinkCounts
Dim i
MaxPerPage = 10
If Request("page")="" Or Not isNumeric(Request("page")) Then
CurrentPage=1
Else
CurrentPage=Cint(Request("page"))
End If
If CurrentPage<1 Then
CurrentPage=1
End If

strHTML = "<?xml version=""1.0"" encoding=""UTF-8""?>" & vbCrLf
strHTML = strHTML & "<!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML 1.1//EN"" ""http://www.wapforum.org/DTD/wml1_1.1.xml"">" & vbCrLf
strHTML = strHTML & "<wml>" & vbCrLf
strHTML = strHTML & "<head>" & vbCrLf
strHTML = strHTML & "<meta http-equiv=""Cache-Control"" content=""max-age=0"" />" & vbCrLf
strHTML = strHTML & "<meta http-equiv=""Cache-Control"" content=""no-cache"" forua=""true"" />" & vbCrLf
strHTML = strHTML & "</head>" & vbCrLf
strHTML = strHTML & "<card title=""KingsNet"">" & vbCrLf
strHTML = strHTML & "<p>" & vbCrLf

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(Server.MapPath("a.txt")) Then Response.End
Set myFile = objFSO.OpenTextFile(Server.MapPath("a.txt"),1,True)
If myFile.AtEndofStream Then Response.End
arrLink = Split(myFile.ReadAll,vbCrLf)
myFile.Close
Set myFile = Nothing
Set objFSO = Nothing

LinkCounts = UBound(arrLink)
If LinkCounts MOD MaxPerPage=0 Then
PageCounts= LinkCounts \ MaxPerPage
Else
PageCounts= LinkCounts \ MaxPerPage+1
End If
If CurrentPage>PageCounts Then CurrentPage=PageCounts
For i = (CurrentPage-1)*MaxPerPage To CurrentPage*MaxPerPage-1
myLine = arrLink(i)
If myLine<>"" Then
strWord = Left(myLine,InStr(myLine," ")-1)
strUrl = Mid(myLine,InStr(myLine," ")+1)
strHTML = strHTML & "<a href="""&strUrl&""">"&strWord&"</a><br/>" & vbCrLf
End If
If i = LinkCounts Then Exit For
Next
strHTML = strHTML & "["&CurrentPage&"/"&PageCounts&"] "
If CurrentPage<2 Then
strHTML = strHTML & "首页 上一页 "
Else
strHTML = strHTML & "<a href=""?Page=1"">首页</a> "
strHTML = strHTML & "<a href=""?Page="&CurrentPage-1&""">上一页</a> "
End If
If PageCounts-CurrentPage<1 Then
strHTML = strHTML & "下一页 尾页"
Else
strHTML = strHTML & "<a href=""?Page="&CurrentPage+1&""">下一页</a> "
strHTML = strHTML & "<a href=""?Page="&PageCounts&""">尾页</a>"
End If

strHTML = strHTML & "</p>" & vbCrLf
strHTML = strHTML & "<p>" & vbCrLf
strHTML = strHTML & "(c) 2001-2009 KingsNet" & vbCrLf
strHTML = strHTML & "</p>" & vbCrLf
strHTML = strHTML & "</card>" & vbCrLf
strHTML = strHTML & "</wml>"
Response.Write Unicode(strHTML)

Function Unicode(ByVal str)
Dim i, j, c, i1, i2, u, fs, f, p
Unicode = ""
p = ""
For i = 1 To Len(str)
c = Mid(str, i, 1)
j = AscW(c)
If j < 0 Then
j = j + 65536
End If
If j >= 0 And j <= 128 Then
If p = "c" Then
Unicode = " " & Unicode
p = "e"
End If
Unicode = Unicode & c
Else
If p = "e" Then
Unicode = Unicode & " "
p = "c"
End If
Unicode = Unicode & ("&#" & j & ";")
End If
Next
End Function
%>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
yanglingbo108
2011-01-09 · TA获得超过1022个赞
知道小有建树答主
回答量:608
采纳率:0%
帮助的人:132万
展开全部
a.txt没试过从这等下读取东西的·一帮都是从数据库读取·
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
熊这得
2011-01-09 · 超过13用户采纳过TA的回答
知道答主
回答量:181
采纳率:0%
帮助的人:78万
展开全部
人格任天堂拼人品俄国人怕看见哟两天后ldfgtl
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式