独舞

  • 首页
  • 程序开发
    • Java
    • 容器
    • 数据库
    • Javascirpt
    • 前端
  • Linux相关
  • 路由和网络
  • 苹果相关
  • 关于
    • 简历
独舞
记录那些朝花夕拾的日子……
  1. 首页
  2. 程序开发
  3. Java
  4. 正文

Spring MVC 找出所有的URL映射地址

2016年4月20日 522点热度 0人点赞 0条评论
@Autowired
private RequestMappingHandlerMapping handlerMapping;
@RequestMapping("urls")
public void index(Long id, HttpServletRequest request, HttpServletResponse response)
			throws IOException, ClassNotFoundException {
		Map<RequestMappingInfo, HandlerMethod> map = handlerMapping.getHandlerMethods();
		Iterator<Entry<RequestMappingInfo, HandlerMethod>> iterator = map.entrySet().iterator();
		while (iterator.hasNext()) {
			Entry<RequestMappingInfo, HandlerMethod> entry = iterator.next();
			HandlerMethod hm=entry.getValue();
			
			StringBuffer str=new StringBuffer("请求地址:"+entry.getKey().getPatternsCondition() + "----调用方法:" + hm.getMethod().getName()+"(");
			MethodParameter[] mmm=hm.getMethodParameters();
			for (MethodParameter methodParameter : mmm) {
				str.append(methodParameter.getParameterType().getSimpleName()+",");
			}
			if(str.lastIndexOf(",")>0){
				str.deleteCharAt(str.length()-1);
			}
			str.append(")");
			System.out.println(str);
			response.setCharacterEncoding("utf-8");
			response.setContentType("text/html");
			response.getWriter().write(str+"<br/>");
		}
	}

标签: 暂无
最后更新:2016年4月20日

Phil

一直以来 我只有前进才能忘记羞辱的历史 所以 还有很多事情 需要我去做 也有很多事情 我必须要做

点赞
< 上一篇
下一篇 >
分类
  • Java / 32篇
  • Javascirpt / 1篇
  • Linux / 40篇
  • Mac / 2篇
  • 前端 / 4篇
  • 区块链 / 2篇
  • 容器 / 8篇
  • 数据库 / 1篇
  • 服务器主机 / 2篇
  • 未分类 / 12篇
  • 程序开发 / 1篇
  • 路由器 / 14篇
广告
广告

COPYRIGHT © 2021 mmgg.net. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

粤ICP备09207437号-5