当前位置:网站首页>基础篇——REST风格开发
基础篇——REST风格开发
2022-07-05 10:46:00 【printf('小白');】
写法
- Representational State Transfer,表现形式状态转换
- 优点
- 隐藏访问行为,无法通过地址得知资源是何种操作
书写简化
- 隐藏访问行为,无法通过地址得知资源是何种操作
http://locahost/users 查询全部用户信息 GET
http://locahost/users/1 查询单个用户信息 GET
http://locahost/users 添加用户信息 POST
http://locahost/users 修改用户信息 PUT
http://locahost/users/1 删除用户信息 DELETE
- 是一种风格不是一种规范,以REST风格开发的叫做RESTFUL
- 描述模块的名称通常用复数,也就是加s的格式描述,表示此类资源,而非单个资源,例如users, books, accounts

几种注解
@RequestBody @RequestParam @PathVariable
- 区别
- @RequestParam它用于接收
url地址传参或者表单传参
@RequestBody用于接收json数据
@PathVariable用于接收路径参数,使用{参数名称}描述路径参数
- @RequestParam它用于接收
- 应用
- 后期开发,发
送请求参数超过一个时,以json为主,@RequestBody 应用较广
发送非json格式数据,选用@RequestParam接收请求参数采用RESTful开发,当参数量较少时,例如一个,可以采用@PathVariable接收请求路径变量,通常用于id传值
- 后期开发,发
@RestController
- 是@Controller 和 @ResponseBody 的集合体
@PostMapping
- @RequestMapping(method = RequestMethod.POST)
边栏推荐
- 2021年山东省赛题库题目抓包
- 正则表达式
- beego跨域问题解决方案-亲试成功
- SQL Server monitoring statistics blocking script information
- 2022 mobile crane driver examination question bank and simulation examination
- About the use of Vray 5.2 (self research notes)
- When using gbase 8C database, an error is reported: 80000502, cluster:%s is busy. What's going on?
- Use bat command to launch common browsers with one click
- Explanation of message passing in DGL
- DOM//
猜你喜欢
随机推荐
Explanation of full vulnerability script of network security C module of secondary vocational group script containing 4 vulnerabilities
数据类型 ntext 和 varchar 在not equal to 运算符中不兼容 -九五小庞
埋点111
括号匹配问题(STL)
中职组网络安全C模块全漏洞脚本讲解包含4个漏洞的脚本
Repair animation 1K to 8K
LSTM applied to MNIST dataset classification (compared with CNN)
基于昇腾AI丨爱笔智能推出银行网点数字化解决方案,实现从总部到网点的信息数字化全覆盖
How can gbase 8C database view the login information of the login user, such as the date, time and IP of the last login authentication?
vite//
【广告系统】Parameter Server分布式训练
vite//
Scaffold development foundation
A mining of edu certificate station
Go language learning notes - first acquaintance with go language
2022年危险化学品生产单位安全生产管理人员特种作业证考试题库模拟考试平台操作
Operation of simulated examination platform of special operation certificate examination question bank for safety production management personnel of hazardous chemical production units in 2022
NAS and San
Web3 Foundation grant program empowers developers to review four successful projects
微信核酸检测预约小程序系统毕业设计毕设(6)开题答辩PPT









