Ruby on Rails 3:如何分别检索POST和GET参数?

时间:2021-10-24 07:34:18

So I know you can get parameters using params, but the thing is that it merges all parameters whether they were sent via GET or POST:

所以我知道你可以使用params获取参数,但问题是它合并了所有参数,无论它们是通过GET还是POST发送的:

If you send a request via GET, no problem, the parameters can only be squeezed in the URL.

如果您通过GET发送请求,没问题,参数只能在URL中挤压。

But if you send a POST request that has a URL like /blabla?foo=bar&foo2=bar2, is there a way to tell the difference between the variables sent via the URL and the variables sent through the actual POST method?

但是如果你发送一个像/ blabla?foo = bar&foo2 = bar2这样的URL的POST请求,有没有办法告诉通过URL发送的变量和通过实际POST方法发送的变量之间的区别?

Hope my question's clear. Thanks!

希望我的问题清楚。谢谢!

1 个解决方案

#1


12  

Yes, in your controller you can get the GET parameters using request.GET and the POST parameters with request.POST

是的,在您的控制器中,您可以使用request.GET获取GET参数,使用request.POST获取POST参数

#1


12  

Yes, in your controller you can get the GET parameters using request.GET and the POST parameters with request.POST

是的,在您的控制器中,您可以使用request.GET获取GET参数,使用request.POST获取POST参数