Given a web app that completely uses @RequestMapping to tie urls to a controller, I was wondering if there is a way or plug-in that would produce the web app's complete url-to-controller mappings?
Similar to struts.xml where you have all the urls mapping to an action hence you can see these information in a central place?
Otherwise, what happens is given a url from the screen, I end up doing a java file search each time I want to lookup that url's controller.
Eclipse has plugin Springsource Tool Suite (you can also download it standalone): http://www.springsource.com/developer/sts You must first add Spring project nature to your project, then switch to Java EE perspective and then you will see "Spring Elements" in your project and there you will see all request mappings (and much more).
edit: useful features like this in STS made me switch from NetBeans to Eclipse.
You can always wire the DefaultAnnotationHandlerMapping and extract all mappings. Something like:
@Autowired
// org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping
private DefaultAnnotationHandlerMapping defaultAnnotationHandlerMapping;
public void outputMappings() {
for (Map.Entry<String, Object> entry :
defaultAnnotationHandlerMapping.getHandlerMap().entrySet()) {
System.out.println(entry.getKey() + "->" +
entry.getValue().getClass().getName());
}
}
See AbstractUrlHandlerMapping.getHandlerMap()
and DefaultAnnotationHandlerMapping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With