工具下载
Postman(发送 http 请求的工具)
官网(下载速度比较慢):https://www.postman.com/downloads/
Http 请求格式

- 请求地址
- 请求方法
- 状态码
- 同源策略
- 请求头
- 响应头
接口类型
- Post 接口(新增数据)
java
@RequestMapping(method = RequestMethod.POST)
@PostMapping("/post")

如果你这样写,是 url 参数,并且 url 参数可以为空
java
@PostMapping("/post") // http://localhost:9090/web/post?name=青哥哥&age=30
public Result post(Obj obj) {
return Result.success(obj);
}

怎么请求 json 数据?
- Put 接口(更新数据)
java
@RequestMapping(method = RequestMethod.PUT)
@PutMapping("/put")

- Delete 接口(删除数据)
java
@RequestMapping(method = RequestMethod.DELETE)
@DeleteMapping("/delete/{id}")

delete 可以传 json 数据,我们批量删除可以使用 delete 类型的接口
- Get 接口
java
@RequestMapping()
或者
@GetMapping("/hello")
怎么定义路由
Http 状态码
- 200:成功
- 400:接口参数错误

- 404:接口路径写错了或者参数写错了

- 405:接口请求类型不匹配
- 500:后台错误
当你的请求出现500 错误 的时候,你应该怎么办?
第一时间,赶紧去看下后台的控制台