<分区>
Possible Duplicates:
How should I choose between GET and POST methods in HTML forms?
When do you use POST and when do you use GET?
显然,你应该这样做。但是这样做除了为了履行HTTP协议(protocol)之外,还有什么理由这样做呢?更少的开销?某种安全措施?
<分区>
Possible Duplicates:
How should I choose between GET and POST methods in HTML forms?
When do you use POST and when do you use GET?
显然,你应该这样做。但是这样做除了为了履行HTTP协议(protocol)之外,还有什么理由这样做呢?更少的开销?某种安全措施?
最佳答案
因为 GET 不能根据定义改变服务器的状态。
参见 RFC2616 9.1.1 Safe Methods :
9.1.1 Safe Methods
Implementors should be aware that the software represents the user in their interactions over the Internet, and should be careful to allow the user to be aware of any actions they might take which may have an unexpected significance to themselves or others.
In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These methods ought to be considered "safe". This allows user agents to represent other methods, such as POST, PUT and DELETE, in a special way, so that the user is made aware of the fact that a possibly unsafe action is being requested.
如果您使用 GET 来更改服务器的状态,那么搜索引擎机器人或 Web 浏览器中的某些链接预取扩展可能会对您的站点造成严重破坏,并且(例如)delete all user data just by following links to your site .
关于http - 那么为什么我们应该使用 POST 而不是 GET 来发布数据呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1254132/