以下为调用http://localhost网址生成的静态网页代码。传递了&html=1&root=0
1句QUERY_STRING会重复html=1&root=0显示为html=1&root=0?html=1&root=0,不属正常,寻原因。
2句QuERY_String显示一次html=1&root=0属正常
为什么http://localhost没有/的时候,会重复?请高手赐教。
以下首页内容index.asp
<!--#include file="inc/global.asa"-->
<%GetHTML%>
getHTML内部执行了Response.Write Request.ServerVariables("QUERY_STRING")用来显示QUERY_STRING的值。
以下静态调用页面makehtml.asp
<%
call makeindex("http://localhost","")-------此为1句,只1斜杆区别
call makeindex("http://localhost/","")------此为2句,只1斜杆区别
Public Sub MakeIndex(domain,lng)
Dim FS, FSO
Set FS = server.CreateObject("Scripting.FileSystemObject")
Set FSO = FS.CreateTextFile(Server.MapPath("../") & "/Index.Html", True)
FSO.Write GetHTML(domain, 0, lng)
Response.Write "<div class=""process"">Index.html</div>"
FSO.Close
Set FSO = Nothing
Set FS = Nothing
End Sub
Public Function GetHTML(url, root, lng)
Dim ObjXML, Unicode
If InStr(url, "?") > 0 Then url = url & "&html=1&root=" & root Else url = url & "?html=1&root=" & root
response.write url &" call<br>"
Set ObjXML =Server.CreateObject("MSXML2.XMLHTTP")
With ObjXML
.Open "GET", url, False
.send
If .readyState = 4 And .Status = 200 Then
GetHTML = BytesToBstr(.responseBody, Unicode)
Else
GetHTML = Err.Description
End If
End With
Set ObjXML = Nothing
End Function
Private Function BytesToBstr(StrBody, Unicode)
Dim ObjStream
Set ObjStream = server.CreateObject("ADODB.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.Write StrBody
.Position = 0
.Type = 2
.Charset = "gbk"
BytesToBstr = .ReadText
.Close
End With
Set ObjStream = Nothing
End Function
%>
------解决方案--------------------