1.post请求:
@RequestMapping(value = "childwatch/bind", method = RequestMethod.POST, produces = CTRL_PRODUCE) public ApiResp bind() { BindChildWatchApiReq req = getRequestObject(BindChildWatchApiReq.class); if (req == null) { return ApiResponse.error(CommonErrorCode.REQUEST_IS_NULL); } return childWatchApiService.bind(req); }
一般会有一个对象如
BindChildWatchApiReq,里面会有post请求的所有参数。
2.get请求:
看如下的一个接口,两个参数会拼接到地址后面

后台代码这样接收

也可以用以下方法 @RequestParam 进行注解(使用另一个接口作为例子):
3.put请求:
get一般传参数只进行查询,对数据不做修改。put一般是修改数据。
如请求一个地址请求地址:http://ip:port/contextPath/api/v1/member/{memberId}/childwatch/phone
请求参数:watchPhone
在postman工具(一种进行get,post提交的工具)中这样请求:http://127.0.0.1:10004/api/v3/zVadT9eSkQNz8zPY/childwatch/phone?rnd=ww
可以看出一共传2个参数
memberId和watchPhone
java后台代码如何接收呢,请看下面:
在地址栏里传入的参数这边可以用注解 @PathVariable获得,watchPhone是在对象里获得,和post一样