springBoot获取请求url

@Autowired
WebApplicationContext applicationContext;
@RequestMapping(“inner/getAllUrl.xhtml”)
public List getAllUrl(){
RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
//获取url与类和方法的对应信息
Map map = mapping.getHandlerMethods();
List urlList = new ArrayList<>();
for (RequestMappingInfo info : map.keySet()){
//获取url的Set集合,一个方法可能对应多个url
Set patterns = info.getPatternsCondition().getPatterns();
for (String url : patterns) urlList.add(url);
}
return urlList;
}

你可能感兴趣的:(java,spring,boot,java,前端,运维,intellij-idea)