How to reflectively get list of all controllers (best if not only annotated, but also specified in xml), matching some specfic url in your Spring MVC application?
In case of annotated-only,
@Autowired
private ListableBeanFactory listableBeanFactory;
...
whatever() {
Map<String,Object> beans = listableBeanFactory.getBeansWithAnnotation(RequestMapping.class);
// iterate beans and compare RequestMapping.value() annotation parameters
// to produce list of matching controllers
}
could be used, but what to do in more general case, when controllers may be specified in spring.xml config? And what to do with request-path parameters?
org.springframework.web.bind.annotation.support.HandlerMethodResolver.getHandlerMethods()at runtime and process the returned methods.DefaultAnnotationHandlerMappingand then pull its mapping map, but as I haven't tried this it's not an answer. The alternative is to examine the registered beans for annotations, but there are some twists to this.