Spring框架 - GET和POST之间的区别 [英] Spring Framework - Difference between GET and POST

查看:212
本文介绍了Spring框架 - GET和POST之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring Framework在JSP上开发一个网页,如果页面使用POST动作发送,我知道GET和POST之间的区别;在浏览器区域,似乎没有发送信息,而在GET中则恰恰相反。

I'm developing a web page on JSP by using Spring Framework, I know the difference between GET and POST generally, if the page sends with the POST action; in the browser area, sent information does not seem and in GET it is just the opposite.

在Spring框架中,我通过控制器发送和获取信息编写我的控制器,我使用请求映射,如;

In spring framework, I'm sending and getting informations via Controllers and just before writing my controller, I use Request mapping like;

@RequestMapping(value = "/pri/SuperUser/ResetPassword.qib",method = RequestMethod.GET)
@Override
public ModelandView function(Model model){
...
...

因此,在这种情况下使用GET和POST有什么区别。除了在浏览器字段中看到发送的信息之外,还应该有其他不同的东西。

So, what is the difference between using GET and POST in this case. There should be something else different than just seeing the sent information in the browser field.

推荐答案

听起来你不太了解完全理解GET / POST。

It sounds like you don't quite have GET/POST understood completely yet.

尝试将此视为Web应用程序:

Try thinking of it like this for a web application:

GET
应使用GET方法从服务器检索数据。对同一URL的多个get请求应该是有效的,并且不应该在服务器端更改任何数据。

GET A GET method should be used to retrieve data from the server. Multiple get requests to the same URL should be valid and no data should be changed on the server side.

但是,这并不意味着它不可能GET请求更改服务器端,但您应该尝试确保遵循标准。

However, this doesn't mean it is not possible to make a GET request change things server side, but you should try to make sure you are following the standard.

POST
POST方法应该在需要在服务器端创建,更新或删除数据时使用。多次发出相同的POST请求可能不安全,可能导致数据不一致。
POST请求的内容在请求正文中发送。因此,您没有在浏览器中看到这些参数,但如果您愿意(甚至使用浏览器开发人员工具)很容易看到它们,因此它不比GET请求更安全。

POST A POST method should be used when you need to create, update or delete data on the server side. Making the same POST request multiple times may not be safe and may result in inconsistent data. The content of a POST request is sent in the request body. Hence, you don't see the parameters in your browser, but it is easy to see them if you wanted to (Even using the browser developer tools) so it is no more safe than a GET request.

注意:这是它们在WEB上的一般使用方式,它不是实际的规格,因为还有其他方法可用。如果您正在创建REST服务,您将需要探索其他方法

NOTE: this is how they are used in general on the WEB, it is not the actual spec as there are other methods available. If you are creating a REST service you will want to explore the other methods

(简而言之 - POST - 用于创建数据,PUT - 用于更新数据,DELETE用于删除数据)

(Briefly - POST - for creating data, PUT - for updating data and DELETE for deleting data)

可能值得阅读实际规范以获得完整的理解: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

It may be worth reading the actual spec to get a complete understanding: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

如果你确实想要保护您的HTTP请求,然后可以使用HTTPS上的SSL加密(单独的主题)来完成

If you did want to secure your HTTP requests, then this can be done using SSL encryption over HTTPS (A separate topic)

这篇关于Spring框架 - GET和POST之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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