@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/>");
}
}