列表页的代码:
ASP/Visual Basic代码
- <!--#include file="config.asp"-->
- <ol>
- <%
- Set rs=server.CreateObject("adodb.recordset")
- sql="select * from Article"
- rs.open sql,conn,1,1
- do while not rs.eof
- %>
- <li><a href="article.asp?/<%=rs("id")%>.html"><%=left(trim(rs("title")),30)%></a></li>
- <%
- rs.movenext
- loop
- rs.close
- set rs=Nothing
- %>
- </ol>
articles.asp
ASP/Visual Basic代码
- <!--#include file="config.asp"-->
- <%
- id=request.QueryString("id")
- If id="" Then
- server_v40=Request.ServerVariables("QUERY_STRING")
- id=Int(replace(replace(server_v40,"/",""),".html",""))
- End If
- Call ReadNews(id)'这个函数用来取具体文章明细的
- %>
- <div>
- 标题: <b><%= News_title%></b><br />
- 内容: <%=News_content%>
- </div>
解说一下吧。实现的链接url类似:articles.asp?/110.html
重点就是取得110这个id的值。两步:
-
通过Request.ServerVariables("QUERY_STRING") ,取得了所有的“?”后面的参数,这里就是"/110.html"。
-
再把“/”和“.html”过滤掉。
用这种方法还可以实现“articles.asp?110”,这样的模式.



#1