当前位置:网站首页>基础篇——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)
边栏推荐
- GBase 8c数据库如何查看登录用户的登录信息,如上一次登录认证通过的日期、时间和IP等信息?
- Review the whole process of the 5th Polkadot Hackathon entrepreneurship competition, and uncover the secrets of the winning projects!
- Go-3-第一个Go程序
- go语言学习笔记-初识Go语言
- Share Net lightweight ORM
- 中职组网络安全C模块全漏洞脚本讲解包含4个漏洞的脚本
- 【Oracle】使用DataGrip连接Oracle数据库
- The first product of Sepp power battery was officially launched
- 第五届 Polkadot Hackathon 创业大赛全程回顾,获胜项目揭秘!
- Repair animation 1K to 8K
猜你喜欢

Go-3-the first go program

Review the whole process of the 5th Polkadot Hackathon entrepreneurship competition, and uncover the secrets of the winning projects!

关于vray 5.2的使用(自研笔记)(二)

基于昇腾AI丨以萨技术推出视频图像全目标结构化解决方案,达到业界领先水平

【Oracle】使用DataGrip连接Oracle数据库

购买小间距LED显示屏的三个建议

【DNS】“Can‘t resolve host“ as non-root user, but works fine as root

Go-3-第一个Go程序

A mining of edu certificate station

【广告系统】Parameter Server分布式训练
随机推荐
beego跨域问题解决方案-亲试成功
四部门:从即日起至10月底开展燃气安全“百日行动”
Beego cross domain problem solution - successful trial
Go project practice - Gorm format time field
Web3基金会「Grant计划」赋能开发者,盘点四大成功项目
How to close the log window in vray5.2
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?
Web Components
DOM//
web安全
磨砺·聚变|知道创宇移动端官网焕新上线,开启数字安全之旅!
[JS learning notes 54] BFC mode
2022 t elevator repair operation certificate examination questions and answers
Go-2-Vim IDE常用功能
32:第三章:开发通行证服务:15:浏览器存储介质,简介;(cookie,Session Storage,Local Storage)
九、磁盘管理
Broyage · fusion | savoir que le site officiel de chuangyu mobile end est en ligne et commencer le voyage de sécurité numérique!
Web3 Foundation grant program empowers developers to review four successful projects
When using gbase 8C database, an error is reported: 80000502, cluster:%s is busy. What's going on?
[TCP] TCP connection status JSON output on the server