Spring Boot HTTP接口GET请求

普通传参

@RequestMapping(path = "/{province_id}/{city_id}", method = RequestMethod.GET)
public Object findUser(@PathVariable("province_id") String provinceId,
                       @PathVariable("city_id") String cityId) {

}

GetMapping注解

@GetMapping(value = "/order/list")
public Object orderList(int from, int size) {

}

默认值、参数名、是否必须

@GetMapping(value = "/order/list")
public Object orderList(@RequestParam(defaultValue = "0", name = "page", required = true) int from, int size) {

}

Bean对象传参

@GetMapping("/user/add")
public Object saveUser(User user) {

}

获取http头信息

@GetMapping("/common/get_header")
public Object getHeader(@RequestHeader("access_token") String accessToken, String id) {

}

HttpServletRequest

@GetMapping("/common/servlet_request")
public Object servletRequest(HttpServletRequest request) {

}

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/11/spring-boot-http-interface-get-request/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
Spring Boot HTTP接口GET请求
普通传参 @RequestMapping(path = "/{province_id}/{city_id}", method = RequestMethod.GET) public Object findUser(@PathVariable("provinc……
<<上一篇
下一篇>>
文章目录
关闭
目 录