首页 > 其他 > 详细

string boot中get、post 接口

时间:2020-12-05 19:48:15      阅读:23      评论:0      收藏:0      [点我收藏+]

后端接口:

1.get,调用方式 http://127.0.0.1:8088/xxxx/{id}

技术分享图片

 

 

 

代码如下:

技术分享图片
1 /**
2      * get方式
3      */
4     @RequestMapping(value = "/xxxxx/{id}", method = RequestMethod.GET)
5     public Object xxxxx(@PathVariable int id) {
6         //以下是逻辑处理
7 
8         return xxx;
9     }
View Code

 

2.post

1)调用地址 http://127.0.0.1:8088/xxxx ,入参格式 application/json,{"a":111,"b":"aa"}

 

技术分享图片

 

 

 代码如下:

技术分享图片
 1 /**
 2      * post方式
 3      */
 4     @RequestMapping(value = "/xxxxx", method = RequestMethod.POST)
 5     public Object xxxxx(@RequestBody HashMap<String, String> map)
 6     {
 7         System.out.println("map:"+map);
 8 
 9         //以下是逻辑处理
10         
11 
12         return xxxx;
13     }
View Code

 

2)调用地址 http://127.0.0.1:8088/xxxx ,入参格式 application/form-data 格式 :phone: "18295880001", env: "dev"

 

技术分享图片

 

 代码如下:

技术分享图片
 1 /**
 2      * post方式
 3      */
 4     @RequestMapping(value = "/xxxxx", method = RequestMethod.POST)
 5     public Object xxxxx(@RequestParam(value = "xxx", required = true) String xxx,
 6         @RequestParam(value = "env", required = xxx) String xxx)
 7     {
 8         //以下是逻辑处理
 9 
10         return xxxxx;
11     }
View Code

 

string boot中get、post 接口

原文:https://www.cnblogs.com/whycai/p/14090375.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!