How to show all the routes mapped in a spring based application? In Rails this is done using rake routes.
I use two mapping methods of spring to create the URL-mappings:
If you set the Log4J category for log4j.logger.org.springframework.web
to INFO
or DEBUG
you should see the list of mappings in your server's log (e.g. catalina.out
) when your app starts up.
For example:
INFO: DefaultAnnotationHandlerMapping: Mapped URL path [/about] onto handler [org.bozos.songfight.webapp.spring.controller.RootController@6bc947]
INFO: DefaultAnnotationHandlerMapping: Mapped URL path [/about.*] onto handler [org.bozos.songfight.webapp.spring.controller.RootController@6bc947]
INFO: DefaultAnnotationHandlerMapping: Mapped URL path [/about/] onto handler [org.bozos.songfight.webapp.spring.controller.RootController@6bc947]
...
INFO: SimpleUrlHandlerMapping: Mapped URL path [/login] onto handler [org.springframework.web.servlet.mvc.UrlFilenameViewController@4035acf6]
If you are using Intellij (ultimate edition), then after you build/run the project, you can view the routes in the bottom toolbar Run
-> Endpoints
-> Mappings
.