0
点赞
收藏
分享

微信扫一扫

string boot中get、post 接口

黄昏孤酒 2022-08-11 阅读 70

后端接口:

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

string boot中get、post 接口_端接

 

 

 

代码如下:

string boot中get、post 接口_端接_02

string boot中get、post 接口_json_03

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"}

 

string boot中get、post 接口_json_04

 

 

 代码如下:

string boot中get、post 接口_端接_02

string boot中get、post 接口_json_03

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"

 

string boot中get、post 接口_json_07

 

 代码如下:

string boot中get、post 接口_端接_02

string boot中get、post 接口_json_03

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

 



举报

相关推荐

0 条评论