URL:/cgi-bin/test.cgi?FirstName=Zara&LastName=Ali
获取参数
1
2
3
4
5
|
#!/usr/bin/ruby
require
'cgi'
cgi =
CGI
.
new
cgi[
'FirstName'
]
# => ["Zara"]
cgi[
'LastName'
]
# => ["Ali"]
|
另一种写法
1
2
3
4
5
6
|
#!/usr/bin/ruby
require
'cgi'
cgi =
CGI
.
new
h = cgi.params
# => {"FirstName"=>["Zara"],"LastName"=>["Ali"]}
h[
'FirstName'
]
# => ["Zara"]
h[
'LastName'
]
# => ["Ali"]
|
获取全部参数
1
2
3
4
|
#!/usr/bin/ruby
require
'cgi'
|
本文转自 紫色葡萄 51CTO博客,原文链接:http://blog.51cto.com/purplegrape/1890111,如需转载请自行联系原作者