zoukankan      html  css  js  c++  java
  • post和get、PostMapping、GetMapping和RequestMapping

    • PostMapping、GetMapping和RequestMapping

    PostMapping和GetMapping封装了method=“”,限制了method,更加规范化。

    • post和get的区别:

    通过浏览器的地址栏输入地址,所访问的URL都是get请求,因此如果以post定义方法,那么由于请求与实现的不一致,会返回405错误,method not allowed,  The specified HTTP method is not allowed for the requested resource.

    这归根到底是因为浏览器发送了get请求,而方法只能处理post请求,所以发生的错误

    Get和Post请求的区别:

    1. 哪一些情况下,浏览器会发送get请求

    a. 直接在浏览器地址栏输入某个地址

    b. 点击链接

    c. 表单默认的提交方式

    2. 哪一些情况下,浏览器会发送post请求?

    a. 设置表单method = "post"

    3. get请求的特点

    a. 请求参数会添加到请求资源路劲的后面,只能添加少量参数(因为请求行只有一行,大约只能存放2K左右的数据)(2K左右的数据,看起来也不少。。。)

    b. 请求参数会显示在浏览器地址栏,路由器会记录请求地址

    4. post请求的特点

    a. 请求参数添加到实体内容里面,可以添加大量的参数(也解释了为什么浏览器地址栏不能发送post请求,在地址栏里我们只能填写URL,并不能进入到Http包的实体当中)

    b. 相对安全,但是,post请求不会对请求参数进行加密处理(可以使用https协议来保证数据安全)。

    转自:https://blog.csdn.net/linjpg/article/details/76927075

  • 相关阅读:
    LeetCode 258 Add Digits
    LeetCode 231 Power of Two
    LeetCode 28 Implement strStr()
    LeetCode 26 Remove Duplicates from Sorted Array
    LeetCode 21 Merge Two Sorted Lists
    LeetCode 20 Valid Parentheses
    图形处理函数库 ImageTTFBBox
    php一些函数
    func_get_arg(),func_get_args()和func_num_args()的用法
    人生不是故事,人生是世故,摸爬滚打才不会辜负功名尘土
  • 原文地址:https://www.cnblogs.com/jixiegongdi/p/13427782.html
Copyright © 2011-2022 走看看