与HTTP和REST比较的Get和post方法之间的区别 [英] Difference between Get and post method in comparision with HTTP and REST

查看:478
本文介绍了与HTTP和REST比较的Get和post方法之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是REST新手。我想知道何时使用get方法以及何时使用post方法。在我的文献调查过程中,我发现了这些知识。

I am new to REST. I want to know when to use get methods and when to use post methods. In the process of my literature survey I came across this knowledge.

实际上当我搜索HTTP get和post方法时,我读到了get不编码URL并对后编码URL

Actually when I searched for HTTP get and post methods, I read that get doesnt encode URL and post encodes the URL

当我搜索rest get和post方法时,我读到get方法用于从服务器检索数据,post方法是向服务器添加一些数据。

When I searched for rest get and post methods, I read that get method is used to retrieve data from server and post method is to add some data to server.

但我也读过,休息只不过是使用HTTP的惯例。

But I also read that rest is nothing but a convention to use HTTP.

所以我觉得有些事情在这里是矛盾的。 HTTP的方法有何不同?

So I feel like some things are contradicting here. Are the methods of HTTP different?

请澄清。此外,欢迎任何关于何时使用get和post方法的建议

Please clarify. Also any suggestions on when to use get and post methods are welcome

我从中获得此信息的资源:

Resource from which i got this information:

https://www.ibm.com/developerworks/webservices/library/ws-ful/

http:// www。 cs.tut.fi/~jkorpela/forms/methods.html

推荐答案

GET应该用于检索资源。此操作应该是幂等的,这意味着它不应该更改服务器上的任何状态。

GET should be used to retrieve a resource. This operation should be idempotent, meaning it should not change any state on the server.

POST应该用于向服务器添加新信息。这通常在表示资源容器的URL上执行。 POST将向此容器添加新资源。

POST should be used to add new information to the server. This is usually performed on a URL that represents a "container" of resources. The POST will add a new resource to this container.

PUT应该用于更新现有资源。

PUT should be used to update an existing resource.

DELETE应该是显而易见的。

DELETE should be obvious.

您可能会喜欢这样阅读: http://tomayko.com/writings/rest-to-my-wife

You might enjoy reading this: http://tomayko.com/writings/rest-to-my-wife

这篇关于与HTTP和REST比较的Get和post方法之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆