获取SSM项目中所有的URL
来源:互联网 发布:网络作家收入作假 编辑:程序博客网 时间:2024/05/16 19:02
1、在springmvc配置加上两个bean:
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/>
2、在controller注入RequestMappingHandlerAdapter:
@AutowiredRequestMappingHandlerMapping requestMappingHandlerMapping;
3、controller添加mapping:
@RequestMapping("/index.action") @ResponseBody public Object index(HttpServletRequest request) { List<HashMap<String, String>> urlList = new ArrayList<HashMap<String, String>>(); Map<RequestMappingInfo, HandlerMethod> map = requestMappingHandlerMapping.getHandlerMethods(); for (Map.Entry<RequestMappingInfo, HandlerMethod> m : map.entrySet()) { HashMap<String, String> hashMap = new HashMap<String, String>(); RequestMappingInfo info = m.getKey(); HandlerMethod method = m.getValue(); PatternsRequestCondition p = info.getPatternsCondition(); for (String url : p.getPatterns()) { hashMap.put("url", url); } hashMap.put("className", method.getMethod().getDeclaringClass().getName()); // 类名 hashMap.put("method", method.getMethod().getName()); // 方法名 RequestMethodsRequestCondition methodsCondition = info.getMethodsCondition(); String type = methodsCondition.toString(); if (type != null && type.startsWith("[") && type.endsWith("]")) { type = type.substring(1, type.length() - 1); hashMap.put("type", type); // 方法名 } urlList.add(hashMap); } HashMap<String, Object> result = new HashMap<String, Object>(); result.put("str", urlList); return result; }
注:如果实例化RequestMappingHandlerMapping出错,大概是你项目不仅仅只有一个实例,此时请为你写的bean设置id
阅读全文
0 0
- 获取SSM项目中所有的URL
- django获取项目所有的URL
- django快速获取项目所有的URL
- SpringMVC项目中获取所有URL到Controller Method的映射
- 获取指定URl页面中所有链接
- 项目启动时获取项目中的所有url
- 获取所有文件夹中所有文件url(不包括文件夹)
- 获取所有IE当前浏览的Url
- 获取网页所有的url 正则
- JQuery获取请求url的所有参数
- Spring MVC获取所有注册的url
- 【MVC】获取项目中所有的控制器-试图
- javaWeb项目ssm框架中jdbc.properties文件加载不了或获取不到值的解决方法
- 做web网页项目中如何获取跳转的来源url和当前url.
- 如何在spring boot中获取所有RequestMapping的URL路径列表集?
- ssm java web项目中获取文件路径
- ssm中项目性能的问题
- 项目中xml获取所有子节点
- 报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library
- GPS坐标转换为百度坐标,百度坐标的转换,原始坐标转百度坐标
- Eclipse
- Python——嵌套列表,根据第k维进行排序
- Boost算法库——搜索算法(Boyer-Moore Search)
- 获取SSM项目中所有的URL
- Qt-界面动态图的实现
- python各个操作excel模块的对比
- 从底层驱动 到上层APP的流程(3)
- 欢迎使用CSDN-markdown编辑器
- Spring
- 逻辑回归(Logistic Regression)
- 类和对象
- protobuf 如何解析(大于64MB)超大报文