有趣生活

当前位置:首页>科技>springboot怎么带header请求spring-boot接口header带必传参数token写法

springboot怎么带header请求spring-boot接口header带必传参数token写法

发布时间:2026-07-25阅读(1)

导读日常开发中,总有些接口必须带上token才可以访问。swagger请求参数在header中添加token我通常的写法:@ApiOperation("个人信息....

日常开发中,总有些接口必须带上token才可以访问。

swagger请求参数在header中添加token

我通常的写法:

@ApiOperation("个人信息查询")@GetMapping("detail")@ApiImplicitParams( {@ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "token标记", required = true)})public JsonData detail() { UserVO userVO = userService.findUserDetail(); return JsonData.buildSuccess(userVO);}

不是实体类的入参,还是使用

@ApiImplicitParams({ @ApiImplicitParam-------嵌套在方法上

swagger表现:

{ "code": 0, "data": { "id": 1, "name": "zhangsan", "slogan": "Talk is cheap, show me the code", "sex": 1, "points": 0, "mail": "295789798@qq.com", "head_img": "http://www.baidu.com" }, "msg": null}

过年了,有假期,好好充电,明年金三银四额!

TAGS标签:  springboot  怎么  header  请求  怎么带header请

Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图