当前位置:网站首页>获取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请求方法取值路径
执行结果:
边栏推荐
- When does MySQL use table locks and when does it use row locks?
- assert
- The introduction of AI meta-learning into neuroscience, the medical effect is expected to improve accurately
- Derivative Operations on Vectors and Derivative Operations on Vector Cross and Dot Products
- 架构设计指南 如何成为架构师
- Go语学习笔记 - gorm使用 - 数据库配置、表新增 Web框架Gin(七)
- bin文件夹下的roslyn文件夹
- mysql高阶语句(一)
- PXE efficient mass network capacity
- go : create database records using gorm
猜你喜欢
The Society of Mind - Marvin Minsky
Proof of distance calculation from space vertex to plane and its source code
export , export default,import完整用法
Go uses the mencached cache
如何实时计算日累计逐单资金流
人工肌肉智能材料新突破
VR机器人教你如何正确打乒乓球
Playing script killing with AI: actually more involved than me
Pioneer in Distributed Systems - Leslie Lambert
New breakthrough in artificial muscle smart materials
随机推荐
How to use Swagger, say goodbye to postman
MySql详解基础
上传文件--文件类型大全,图片类型,文档类型,视频类型,压缩包类型
ArrayList
From catching up to surpassing, domestic software shows its talents
【雷达目标检测】恒定阈值法和恒虚警(CFAR)法及代码实现
New breakthrough in artificial muscle smart materials
MySQL题外篇【ORM思想解析】
node.js中实现对数据库的链式操作
The first artificial intelligence safety competition officially launched
MYSQL 主从恢复锁表后, 处理SQL 线程锁解决.
go : create database records using gorm
理解和熟悉递归中的尝试
千万级数据量的表,怎样最快速度查询?
深度学习:线性回归模型
Electron日常学习笔记
MySQL master-slave replication configuration construction, one step in place
AI can identify race from X-rays, but no one knows why
Electron之初出茅庐——搭建环境并运行第一个程序
go : go-redis 基础操作