当前位置: 首页 > news >正文

哈尔滨网站设计公司好平面设计学习

哈尔滨网站设计公司好,平面设计学习,石家庄网站建设兼职,能源网站建设文章目录 说明效果创建GET请求没有参数带有参数带有环境变量带有动态参数 说明 首先通过###三个井号键来分开每个请求体,然后请求url和header参数是紧紧挨着的,请求参数不管是POST的body传参还是GET的parameter传参,都是要换行的,…

文章目录

  • 说明
  • 效果
  • 创建GET请求
    • 没有参数
    • 带有参数
    • 带有环境变量
    • 带有动态参数

说明

在这里插入图片描述

首先通过###三个井号键来分开每个请求体,然后请求url和header参数是紧紧挨着的,请求参数不管是POST的body传参还是GET的parameter传参,都是要换行的,需要遵守HTTP协议规范

GET请求

### GET request with a header
GET https://httpbin.org/ip
Accept: application/json### GET request with parameter
GET https://httpbin.org/get?show_env=1
Accept: application/json### GET request with environment variables
GET {{host}}/get?show_env={{show_env}}
Accept: application/json### GET request with disabled redirects
# @no-redirect
GET http://httpbin.org/status/301### GET request with dynamic variables
GET http://httpbin.org/anything?id={{$uuid}}&ts={{$timestamp}}###

POST请求

### Send POST request with json body
POST https://httpbin.org/post
Content-Type: application/json{"id": 999,"value": "content"
}### Send POST request with body as parameters
POST https://httpbin.org/post
Content-Type: application/x-www-form-urlencodedid=999&value=content### Send a form with the text and file fields
POST https://httpbin.org/post
Content-Type: multipart/form-data; boundary=WebAppBoundary--WebAppBoundary
Content-Disposition: form-data; name="element-name"
Content-Type: text/plainName
--WebAppBoundary
Content-Disposition: form-data; name="data"; filename="data.json"
Content-Type: application/json< ./request-form-data.json
--WebAppBoundary--### Send request with dynamic variables in request's body
POST https://httpbin.org/post
Content-Type: application/json{"id": {{$uuid}},"price": {{$randomInt}},"ts": {{$timestamp}},"value": "content"
}###

效果

点击项目目录,右键操作,new,Http Request
在这里插入图片描述

hello.http

GET http://localhost:8080/validSingleColumn
Accept: application/json

RUN 返回信息

GET http://localhost:8080/validSingleColumnHTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 06:28:03 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "操作成功","code": 200,"data": ["1","2","3","4","5"]
}Response code: 200; Time: 49ms; Content length: 54 bytes

在这里插入图片描述
在resource下面新建一个包,如rest、http之类的,名字随便取,在这里面我们来创建我们的请求。

创建GET请求

没有参数

GET http://localhost:8080/hello
Accept: application/json

controller

 @GetMapping(value = "hello")public AjaxResult hello(){return AjaxResult.success("hello");}

响应信息

GET http://localhost:8080/helloHTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 06:41:52 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "hello","code": 200
}Response code: 200; Time: 279ms; Content length: 26 bytes

带有参数

第一种形式:使用@RequestParam单个参数

    @GetMapping(value = "/getFirst")public AjaxResult getFirst(@RequestParam String id) {log.info("id:【{}】", id);return AjaxResult.success("使用@RequestParam单个参数");}
GET http://localhost:8081/hello/getFirst?id=1
Accept: application/json
GET http://localhost:8081/hello/getFirst?id=1HTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 06:59:52 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "使用@RequestParam单个参数","code": 200
}Response code: 200; Time: 62ms; Content length: 40 bytes

第二种方式:不使用@RequestParam单个参数

@GetMapping(value = "getSecond")
public AjaxResult getSecond(String id) {log.info("id:【{}】", id);return AjaxResult.success("不使用@RequestParam单个参数。");
}
GET http://localhost:8081/hello/getSecond?id=2
Accept: application/json
GET http://localhost:8081/hello/getSecond?id=2HTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 07:01:52 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "不使用@RequestParam单个参数。","code": 200
}Response code: 200; Time: 14ms; Content length: 42 bytes

第三种方式:多个基础参数

    @GetMapping(value = "getThird")public AjaxResult getThird(String id, int age) {log.info("id:【{}】,age:【{}】", id, age);return AjaxResult.success("多个参数");}
GET http://localhost:8081/hello/getThird/?id=18&age=16
Accept: application/json
GET http://localhost:8081/hello/getThird/?id=18&age=16HTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 07:05:24 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "多个参数","code": 200
}Response code: 200; Time: 15ms; Content length: 25 bytes

第四种方式:多个参数使用@RequestParam

    @GetMapping(value = "getFourth")public AjaxResult getFourth(@RequestParam String id, @RequestParam int age) {log.info("id:【{}】,age:【{}】", id, age);return AjaxResult.success("多个参数使用@RequestParam");}
GET http://localhost:8081/hello/getFourth?id=18&age=16
Accept: application/json
GET http://localhost:8081/hello/getFourth?id=18&age=16HTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 07:07:19 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "多个参数使用@RequestParam","code": 200
}Response code: 200; Time: 20ms; Content length: 40 bytes

第五种方式:map入参使用@RequestParam,其实加不加一样效果

    @GetMapping(value = "getFifth")public AjaxResult getFifth(@RequestParam Map map) {log.info("map:【{}】", map);return AjaxResult.success("map使用@RequestParam");}
GET http://localhost:8081/hello/getFifth?id=1&age=10
Accept: application/json
GET http://localhost:8081/hello/getFifth?id=1&age=10HTTP/1.1 200 
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 07:13:03 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "map使用@RequestParam","code": 200
}Response code: 200; Time: 13ms; Content length: 39 bytes

第六种:实体类使用

    @GetMapping(value = "getSeven")public AjaxResult getSeven(User user) {log.info("user:【{}】", user);return AjaxResult.success("实体类");}
GET http://localhost:8081/hello/getSeven?id=10&age=10&userName=pmb
Accept: application/json
GET http://localhost:8081/hello/getSeven?id=10&age=10&userName=pmbHTTP/1.1 200 
X-xr-bookmark: 1b995c1b-c0c7-4b3b-8d9b-9c0c008f7b32
Content-Type: application/json
Transfer-Encoding: chunked
Date: Thu, 27 Jul 2023 07:30:10 GMT
Keep-Alive: timeout=60
Connection: keep-alive{"msg": "实体类","code": 200
}Response code: 200; Time: 75ms; Content length: 24 bytes

在这里插入图片描述
总结:接收一个参数(String、Long),接收一个集合(Map)
  GET 请求 测试发现 使用 @RequestParm 可以接收到参数
  GET 请求 测试发现 不加 @RequestParm 也可以接收到参数

接受一个对象(user)
  GET 请求 测试发现 使用 @RequestParm 接收对象 报错 接收不到
  GET 请求 测试发现 不加 @RequestParm 接收对象 可以接收

总结:
GET 请求 当使用 @RequestParm 注解 和 不加注解时,只能接收到 params 携带的参数 ,参数放在 请求头 和请求体中均接受不到。

带有环境变量

带有动态参数

接收一个参数(String、Long、Integer)@RequestParm 可以。
接收一个集合(Map)@RequestParm 和 @RequestBody 均可以。
接收一个对象(user) @RequestBody 均可以。

总结:POST请求 当使用 @RequestParm 注解 和 不加注解时,只能接收到 params 和请求体xxx格式携带的参数,加注解无法接收到对象参数。
http://www.yayakq.cn/news/712726/

相关文章:

  • 电脑自己做网站可以吗龙岗做商城网站建设
  • 东莞网站设计百年网站浏览路径怎么做
  • 直播网站怎么做啊福田附件网站建设公司
  • html5 微网站 免费react是网站开发
  • 开发一个网站能赚多少钱wordpress主题首页文件夹
  • 用python做网站优点四川省的建设厅注册中心网站首页
  • 淄博seo网站排名优化网络营销到底是干嘛的
  • 古镇网站建设公司wordpress 视频加速
  • 淘宝客 wordpress网站深圳模具设计公司
  • 好的网站设计网站给我免费播放在线
  • 宁德城乡住房建设厅网站如何再腾讯云服务器做网站
  • 怎么用ftp工具上传网站源码微信小程序怎么下载
  • 南京网站优化多少钱儿童网站源码
  • 类似于微博网站怎么做的织梦做的网站怎么样
  • 网站素材免费国内免费网站服务器推荐
  • 秦皇岛金洋建设集团网站广州市企业网站制作公司
  • 银行需要网站开发人员吗重庆seo网络推广平台
  • 手机wap网站模板下载网站建设亿玛酷信赖
  • 浙江住房和建设网站广州做网站开发
  • 做网站考什么赚钱wordpress付费播放器
  • 免费建站网站一级大wordpress添加视频
  • 网站建设服务器如何选择h5生成
  • 衡阳网站优化外包价格4399全部网页游戏大全
  • 办个网站多少钱小程序制作模板网站
  • 网站建设的收获wordpress 不能查看站点
  • 制作网站建设规划书进腾讯做游戏视频网站
  • 东莞网站设计企业网站开发网
  • 企业建设网站 入账设计公司logo最重要的是什么
  • 网站关键词锚文本指向网页设计与制作课程内容
  • 宿州市埇桥区建设局网站全球新冠疫苗接种率