当前位置:网站首页>获取controller中所有接口路径和名称
获取controller中所有接口路径和名称
2022-07-30 05:57:00 【森林迷了~鹿】
获取controller中所有接口路径和名称
@Autowired
WebApplicationContext applicationContext;
@GetMapping("/getInterfacePath")
public Map getInterfacePath(){
RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
// 拿到Handler适配器中的全部方法
Map<RequestMappingInfo, HandlerMethod> methodMap = mapping.getHandlerMethods();
HashMap<String, String> urlMap = new HashMap<>();
for (RequestMappingInfo info : methodMap.keySet()){
//获取请求路径
Set<String> urlSet = info.getPatternsCondition().getPatterns();
// 获取全部请求方式
//Set<RequestMethod> Methods = info.getMethodsCondition().getMethods();
//获取全部请求名称
String urlName = info.getName();
for (String url : urlSet){
if(StrUtil.isNotBlank(urlName)){
urlMap.put(urlName,url);
}
}
}
return urlMap;
}
需要获取到接口名称需要添加name属性
@PostMapping(value = "updateRole", name = "修改用户角色")
接口路径、名称、http请求方法取值路径
执行结果:
边栏推荐
猜你喜欢

Graphical relational database design ideas, this is too vivid

万能js时间日期格式转换

IDEA搜索插件无结果一直转圈圈的解决办法

分布式系统中的开创者—莱斯利·兰伯特

Rodrigues: vector representation of rotation matrices

不会吧,Log4j 漏洞还没有完全修复?

专访蚂蚁:这群技术排头兵,如何做好底层开发这件事?| 卓越技术团队访谈录

The introduction of AI meta-learning into neuroscience, the medical effect is expected to improve accurately

Playing script killing with AI: actually more involved than me

The first artificial intelligence safety competition officially launched
随机推荐
roslyn folder under bin folder
Boot process and service control
What new materials are used in the large aircraft C919?
No, the Log4j vulnerability hasn't been fully fixed yet?
从 Google 离职,前Go 语言负责人跳槽小公司
首届人工智能安全大赛正式启动
go : go gin returns JSON data
手机端滚动至页面指定位置
Redis 如何实现防止超卖和库存扣减操作?
Mobile phone side scroll to page to specify location
go : create database records using gorm
Electron之初出茅庐——搭建环境并运行第一个程序
LVM and disk quotas
Proof of distance calculation from space vertex to plane and its source code
2020 数学建模之旅
VR机器人教你如何正确打乒乓球
DNS domain name resolution services
The calculation and source code of the straight line intersecting the space plane
MYSQL下载及安装完整教程
STL源码剖析:class template explicit specialization代码测试和理解