@Autowired
WebApplicationContext applicationContext; @RequestMapping(value = "v1/getAllUrl", method = RequestMethod.POST)
public Object getAllUrl() {
RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
// 获取url与类和方法的对应信息
Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods(); // List<String> urlList = new ArrayList<>();
// for (RequestMappingInfo info : map.keySet()) {
// // 获取url的Set集合,一个方法可能对应多个url
// Set<String> patterns = info.getPatternsCondition().getPatterns();
//
// for (String url : patterns) {
// urlList.add(url);
// }
// } List<Map<String, String>> list = new ArrayList<Map<String, String>>();
for (Entry<RequestMappingInfo, HandlerMethod> m : map.entrySet()) {
Map<String, String> map1 = new HashMap<String, String>();
RequestMappingInfo info = m.getKey();
HandlerMethod method = m.getValue();
PatternsRequestCondition p = info.getPatternsCondition();
for (String url : p.getPatterns()) {
map1.put("url", url);
}
map1.put("className", method.getMethod().getDeclaringClass().getName()); // 类名
map1.put("method", method.getMethod().getName()); // 方法名
RequestMethodsRequestCondition methodsCondition = info.getMethodsCondition();
for (RequestMethod requestMethod : methodsCondition.getMethods()) {
map1.put("type", requestMethod.toString());
} list.add(map1);
}

最新文章

  1. Python写各大聊天系统的屏蔽脏话功能原理
  2. UDP Server
  3. Linux练习
  4. Gradle的安装与配置
  5. fastjson对Date的处理
  6. asp.net中水印的实现代码
  7. js切换换class
  8. CodeForces 591B
  9. easyui tree 的数据格式转换
  10. Android okHttp网络请求库详解
  11. Window10上安装Redis及其客户端
  12. Oracle通过Navicat导入表数据与机构,数据无法直接查询,需要加双引号的问题
  13. 【原创】大数据基础之Ambari(1)简介、编译安装、使用
  14. BZOJ3996[TJOI2015]线性代数——最小割
  15. 「About Blockchain(一)」达沃斯年会上的区块链
  16. Thinkphp 中的自动验证 上一篇有例子
  17. Django 正向解析与反向解析
  18. ckeditor富文本编辑器的基本配置设置:
  19. Redis管道传输
  20. Luogu 3245 大数

热门文章

  1. ASP.NET 检测当前计算机及登录用户名
  2. Qt5MV自定义模型与实例浅析
  3. lucene Hello World
  4. java.io.NotSerializableException:异常解决
  5. erase
  6. elastic query match_all 数据目标超过10000条出错 Result window is too large
  7. frame window 和open 的关系
  8. 文件包含 &amp; LFI-labs靶场
  9. DC-9 靶机渗透测试
  10. JAVA数组的基础入门&gt;从零开始学java系列