Get请求:
@ApiOperation("手机号码归属地查询")
@RequestMapping(value = "/phoneAttributionQuery/{mobile}", method = RequestMethod.GET)
@ResponseBody
public Response phoneAttributionQuery(@PathVariable("mobile") String mobile){
try{
Response response = phoneNumberService.phoneAttributionQuery(mobile);
return response;
}catch(Exception e){
logger.error("手机号码归属地查询异常:{}", e);
return Response.error("手机号码归属地查询异常");
}
}
请求url>> http://localhost:9292/third/phoneApi/phoneAttributionQuery/1XXXXXX9539
@ApiOperation("手机号码归属地查询")
@RequestMapping(value = "/phoneAttributionQuery", method = RequestMethod.GET)
@ResponseBody
public Response phoneAttributionQuery2(@RequestParam("mobile") String mobile){
try{
Response response = phoneNumberService.phoneAttributionQuery(mobile);
return response;
}catch(Exception e){
logger.error("手机号码归属地查询异常:{}", e);
return Response.error("手机号码归属地查询异常");
}
}
请求url>> http://localhost:9292/third/phoneApi/phoneAttributionQuery?mobile=1XXXXXX9539
Springboot接口注解PathVariable和RequestParam的区别
原文:https://www.cnblogs.com/ddfly1/p/14266964.html