首页
统计
关于
Search
1
Sealos3.0离线部署K8s集群
1,082 阅读
2
类的加载
741 阅读
3
Spring Cloud OAuth2.0
726 阅读
4
SpringBoot自动装配原理
691 阅读
5
集合不安全问题
584 阅读
笔记
Java
多线程
注解和反射
JVM
JUC
设计模式
Mybatis
Spring
SpringMVC
SpringBoot
MyBatis-Plus
Elastic Search
微服务
Dubbo
Zookeeper
SpringCloud
Nacos
Sentinel
数据库
MySQL
Oracle
PostgreSQL
Redis
MongoDB
工作流
Activiti7
Camunda
消息队列
RabbitMQ
前端
HTML5
CSS
CSS3
JavaScript
jQuery
Vue2
Vue3
Linux
容器
Docker
Kubernetes
Python
登录
Search
标签搜索
Java
CSS
mysql
RabbitMQ
JavaScript
Redis
JVM
Mybatis-Plus
Camunda
多线程
CSS3
Python
Spring Cloud
注解和反射
Activiti
工作流
SpringBoot
Mybatis
Spring
html5
蘇阿細
累计撰写
388
篇文章
累计收到
4
条评论
首页
栏目
笔记
Java
多线程
注解和反射
JVM
JUC
设计模式
Mybatis
Spring
SpringMVC
SpringBoot
MyBatis-Plus
Elastic Search
微服务
Dubbo
Zookeeper
SpringCloud
Nacos
Sentinel
数据库
MySQL
Oracle
PostgreSQL
Redis
MongoDB
工作流
Activiti7
Camunda
消息队列
RabbitMQ
前端
HTML5
CSS
CSS3
JavaScript
jQuery
Vue2
Vue3
Linux
容器
Docker
Kubernetes
Python
页面
统计
关于
搜索到
1
篇与
的结果
2020-12-17
RestFul风格
RestFul风格RestFul就是一个资源定位及资源操作的风格,它不是标准也不是协议,基于这个风格设计的软件可以更简洁,更有层次,更易于实现缓存等机制。传统资源操作方式:http://127.0.0.1/project/findUser.do?id=1 查询 GEThttp://127.0.0.1/project/addUser.do 新增 POSThttp://127.0.0.1/project/modifyUser.do 更新 POSThttp://127.0.0.1/project/deleteUser.do?id=1 删除 GET或POST使用RestFul风格:http://127.0.0.1/project/1 查询 GEThttp://127.0.0.1/project 新增 POSThttp://127.0.0.1/project 更新 POSThttp://127.0.0.1/project/1 删除 GET或POST常用的资源操作:POST、DELETE、PUT、GETpackage com.sw.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * @Author suaxi * @Date 2020/12/17 11:25 */ @Controller public class RestFulController { //传统风格 http://localhost:8088/add01?a=1&b=1 @RequestMapping(value = "/add01/{a}/{b}",method = RequestMethod.GET) public String test01(@PathVariable int a,@PathVariable int b, Model m){ int result = a + b; m.addAttribute("msg","结果1为:"+result); return "hello"; } //简化 http://localhost:8088/add02/1/2 @PostMapping("/add02/{a}/{b}") public String test02(@PathVariable int a,@PathVariable int b, Model m){ int result = a + b; m.addAttribute("msg","结果2为:"+result); return "hello"; } } 注:@PathVariable 让方法参数的值对应绑定到一个URI模板变量上
2020年12月17日
78 阅读
0 评论
0 点赞