If it has no associated data, it will come in as a GET request. If instead it contains form data, we’ll see a POST. Inside a Rails controller, the request information is available in the attribute request. We can check the request type using the methods get?( ) and post?( ).
也就是说当没有数据的时候,是get,而有数据的时候则是post.
例如我们在用户登录的时候,首先转到登录界面,这个时候当然还没有数据,那么
request.get?
为true,输入相应的数据,提交为false,这样我们可以通过一个action来控制流程
为true,输入相应的数据,提交为false,这样我们可以通过一个action来控制流程
def login
if request.get?
session[:user_id]=nil
@user = User.new
else
@user = User.new(params[:user])
logged_in_user = @user.try_to_login
if logged_in_user
session[:user_id]=logged_in_user.id
redirect_to :action=>'index'
else
flash[:notice]="Invalid user/password combination"
end
end
end
if request.get?
session[:user_id]=nil
@user = User.new
else
@user = User.new(params[:user])
logged_in_user = @user.try_to_login
if logged_in_user
session[:user_id]=logged_in_user.id
redirect_to :action=>'index'
else
flash[:notice]="Invalid user/password combination"
end
end
end
相关推荐
一个关于post和get方式传输数据的不同点的分析
PHP封装cUrl库,实现post登录,get请求资源。支持cookie。 内附使用方法,公司打卡的小案例。
import postAndGet_result.java 事务开始 public static void main(String[] args) { //发送 GET 请求 String s=postAndGet_result.sendGet("http://localhost:xxxxxx", "key=123&v=456"); System.out....
中国最大的物联网云平台Yeelink,为您提供传感器云服务; 并通过实时数据处理, 为您提供安全可靠的状态监控。
用于VC & VS C++开发 Http封装类,无需再次封装
強大HTTP TOOL AT Qt, 支援post and get
Get Post实现,支持cookie定义
General POST and GET commands shall be covered here. Chapter 3, Working with Taxonomies and Users with REST API, moves to taxonomies such as categories and tags. Users and user roles will also be ...
用户在开发或者调试网络程序或者是网页B/S模式的程序的时候是需要一些方法来跟踪网页请求的,用户可以使用一些网络的监视工具比如著名的Firebug等网页调试工具。今天给大家介绍的这款网页调试工具不仅可以调试简单的...
用来测试webapi接口,get和post请求测试,用来测试webapi接口,get和post请求测试,
Docker example for Post and Get request
Android HttpUrlConnection使用方法 post and get json.
AJAX发送请求与接受,入门知识很好很基出,POSTANDGET
* *描 述:实现HTTP协议中的GET、POST请求 * *使 用:HttpProc.WebClient client = new HttpProc.WebClient(); client.Encoding = System.Text.Encoding.Default;//默认编码方式,根据需要设置其他类型 client....
The WinHTTP is easy to use WinInet-based HTTP client component which allows to post and get any data from the Web via HTTP protocol.
The WinHTTP is easy to use WinInet-based HTTP client component which allows to post and get any data from the Web via HTTP protocol.
Get familiar with using plugins, and extend PostCSS with the API Build a fully working custom preprocessor and test it on different sites such as WordPress Write a custom syntax in PostCSS while still...
本文实例讲述了python通过get,post方式发送http请求和接收http响应的方法。分享给大家供大家参考。具体如下: 测试用CGI,名字为test.py,放在apache的cgi-bin目录下: #!/usr/bin/python import cgi def main(): ...
Retrofit Okhttp辅助类的简单封装,vesion 1.0.X 实现了Get,Post-Form、Post-Json 三种形式的网络请求,后续版本会实现文件上传下载and各类raw的请求方式。
1.1 Goals of a Plug and Play System BIOS 4 1.2 Enhancements to the current BIOS architecture 5 1.3 Elements of the Plug and Play BIOS architecture 6 1.3.1 Bi-modal functionality 6 1.3.2 OS ...