您的位置:程序门 -> web 开发 -> asp



asp传递时如何传递未知个参数


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


asp传递时如何传递未知个参数
发表于:2008-01-22 15:08:55 楼主
我的意思是,可以通过index.asp?n1=1&n2=2这样的连接来传递n1和n2,但我有未知个参数index.asp?n1=1&n2=2......&nn=n,我不能确定n,又无法用循环,因为我要用fso来geturl(),所以不能用post加循环来提交这么多参数.  
我通过这个来接收参数  
<%  
bj=trim(request("bj"))  
rwdm=trim(request("rwdm"))  
do       while       not       aac=0  
EXECute("xt"&ii&"="""&trim(request("xt"&ii&""))&"""")  
EXECute("ck"&ii&"="""&trim(request("ck"&ii&""))&"""")      
aac=aac-1  
%>  
aac可以通过查找数据库来确定,然后  
<%  
dim               wstr,str,url,start,over,id1              
                    sid=1  
       
        url="http://192.168.154.144/n/m3print2.asp?keyword="&id&"&bj="&bj&"&xt1="&xt1&"&&"&xt2="&xt2&"&......"问题在这,没办法确定有几个xt  
        wstr=gethttppage(url)                      
        start=newstring(wstr,"   <html>   ")              
        over=newstring(wstr,"   </html>   ")              
        body=mid(wstr,start,over-start)               '这里可能要合理加减几个字节              
        set               fso               =               server.createobject("scripting.filesystemobject")              
        fname=sid               &               ".htm"              
        fpath=server.mappath(".")               '当前目录下生成htm文件              
                if               fso.fileexists(fpath               &               "\"               &               fname)=true               then              
        response.write               "该文件已经存在!"              
        else              
        set               fout               =               fso.createtextfile(fpath               &               "\"               &               fname)              
        fout.writeline               body              
        fout.close              
        set               fout=nothing              
        set               fso=nothing                      

%>  
发表于:2008-01-22 15:36:321楼 得分:0
get方式:request.querystring.count
post方式:request.form.count
for   each   可以遍历传递的参数
eg:
for   each   item   in   request.querystring
      response.write   item   &   chr(9)   &   request.querystring(item)   &vbcrlf
next
发表于:2008-01-22 15:39:202楼 得分:0
vbscript code
'================================================================== 'geturl 得到当前的url并将querystring,form的参数全部转化为querystring '返回的url已经过编码 '================================================================== function geturl() dim url_host,url_string url_string="" url_host=request.servervariables("script_name") if request.querystring<>"" then dim get_query for each get_query in request.querystring if url_string="" then url_string=get_query&"="&request.querystring(get_query) else url_string=url_string&"&"&get_query&"="&request.querystring(get_query) end if next end if if request.form<>"" then dim post_query for each post_query in request.form if url_string="" then url_string=post_query&"="&request.form(post_query) else url_string=url_string&"&"&post_query&"="&request.form(post_query) end if next end if if len(url_string)>0 then url_string = url_host&"?"&url_string else url_string = url_host end if geturl=server.urlencode(url_string) ' or geturl=url_string end function
发表于:2008-01-22 16:07:433楼 得分:0
不懂啊,两位大哥,有没有简单点的办法啊,我的真正目的是要自动存储这个页面到指定目录,可是?号好接的是不确定个数的参数,简单点让我能用啊


快速检索

最新资讯
热门点击