ASP传递参数的问题
来源:百度知道 编辑:UC知道 时间:2024/05/22 04:45:24
参数中带有#号,接收参数后#后的不显示出来了
咋办?
as.asp?str = "123#456"
<%
response.write request(str)
%>
就只显示123
咋办?
as.asp?str = "123#456"
<%
response.write request(str)
%>
就只显示123
使用URLEncode
<a href="b.asp?id=<%=server.URLEncode("123#456")%>">go</a>
可见在地址栏中的“#”变成了%23,使用了URLEncode后就正常了。
<%
response.write request.querystring(replace(str,"#","#"))
%>
传get参数时尽量
采用URL编码
server.urlencode()
这样对中文字符和特殊符号就不会丢失了,
你的你的题目中,
因为有url后面的#表示书签,那么碰到#系统会认为是书签会去找本网页是否含有<a name="456"></a>的地方进行定位,而不反它当成前面参数的一部分,所以应该用
asp?id=<%=server.URLEncode("123#456")%>这种方式转换编码