Spring mvc(3)如何获取所有的requestMapping
来源:互联网 发布:淘宝店铺淘金币签到 编辑:程序博客网 时间:2024/06/07 02:09
Java 代码
@AutowiredApplicationContext context;private Map<Object, Object> requestMappings() { Map<String, Object> map = context.getBeansWithAnnotation(Controller.class); Map<Object, Object> mappingsMap = new LinkedHashMap<>(); for (Map.Entry<String, Object> entry : map.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); String[] classMappingStrs = getReqMappingValues(value); ArrayList<String[]> list = new ArrayList<>(); for (Method m : value.getClass().getMethods()) { String[] methodStrs = getReqMappingValuesFromMethod(m); if (!Util.isEmpty(methodStrs)) { list.add(methodStrs); } } for (String str : classMappingStrs) { for (String[] ss : list) { for (String s : ss) { mappingsMap.put(str+s, key); } } } LogCore.BASE.info("look controller key= {}, v{}", key, value.getClass().getName()); } return mappingsMap; }
private String[] getReqMappingValues(Object value) { String[] v3 = Util.toNullDefalut(value.getClass().getAnnotation(RequestMapping.class), RequestMapping::value, new String[]{""}); return v3; } private String[] getReqMappingValuesFromMethod(Method method) { String[] v3 = Util.toNullDefalut(method.getAnnotation(RequestMapping.class), RequestMapping::value, new String[]{}); return v3; }
/** * @param s * @param func s如果不为null,则执行此表达式 * @param nullDefalut 如果s为null直接返回这个值 */ public static <T,R> R toNullDefalut(T t,Function<T, R> func, R nullDefalut){ if(null == t){ return nullDefalut; } return func.apply(t); }
阅读全文
0 0
- Spring mvc(3)如何获取所有的requestMapping
- Spring 的MVC @RequestMapping
- Spring 的MVC @RequestMapping
- 如何在spring boot中获取所有RequestMapping的URL路径列表集?
- spring-mvc @RequestMapping 获取url路径参数
- Spring MVC获取所有注册的url
- spring mvc中的@RequestMapping的用法
- spring mvc中的@RequestMapping的用法
- spring mvc中的@RequestMapping的用法
- Spring MVC (2) 注解RequestMapping的使用
- Spring MVC 中的 @RequestMapping 的使用方法
- 用于获取spring所有支持的请求url,也就是{@link RequestMapping}的url
- Spring Mvc @RequestMapping 详解
- Spring MVC @RequestMapping
- Spring MVC @RequestMapping使用方法
- Spring MVC RequestMapping
- Spring MVC 中的RequestMapping
- Spring MVC @RequestMapping
- 常用的日期格式化转换符
- pip安装的时候报错
- Linux android下常用命令
- HDU
- 类加载器子系统
- Spring mvc(3)如何获取所有的requestMapping
- TIME_WAIT状态
- Spring Boot (教程七: servlet)
- LeetCode 16. 3Sum Closest
- java学习第一天
- MyBatis 持久层框架
- 前台向后台传递参数时,特殊字符(+、-)丢失的问题
- tensorflow安装(windows,linux均可)
- 标签和js对象绑定事件以及传参问题