与HTTP和REST比较的Get和post方法之间的区别

编程入门 行业动态 更新时间:2024-10-12 03:27:38
本文介绍了与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:

www.ibm/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.

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

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

更多推荐

与HTTP和REST比较的Get和post方法之间的区别

本文发布于:2023-10-10 21:26:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479792.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   方法   HTTP   REST   post

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!