问题描述
如何显示基于Spring的应用程序中映射的所有路由?在Rails中,这是通过耙路径完成的。
How to show all the routes mapped in a spring based application? In Rails this is done using rake routes.
我使用spring的两种映射方法来创建URL映射:
I use two mapping methods of spring to create the URL-mappings:
-
@RequestMapping
-
SimpleUrlHandler
@RequestMapping
SimpleUrlHandler
我使用了Unix命令 grep
和 cut
以获取 @RequestMapping
的所有映射。我想知道是否可以通过某种方式从Spring应用程序中获取这些详细信息。
I have used the Unix command grep
and cut
to get all the mappings of @RequestMapping
. I wonder if there is some way I can get these details from the Spring application.
推荐答案
如果为 log4j.logger.org.springframework.web
到 INFO
或 DEBUG
您应该在应用启动时在服务器日志中看到映射列表(例如 catalina.out
)。
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.
例如:
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]
这篇关于如何显示春季的所有可用路线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!