在jsp文件中显示spring @controller提供的rest服务
我目前有一组由 Spring 3.1.0 @Controller 提供的休息服务,并且想知道是否有任何方法可以轻松地在我的 index.jsp 文件中提供服务列表(指向休息服务的链接)。我知道反射是一种选择,但我认为 spring 可能有办法查看 @Controller 提供的服务并允许我显示它们。
I currently have a group of rest services provided by Spring 3.1.0 @Controller and wondered if there was any way that I could easily provide a list of the services (links to the restful services) in my index.jsp file. I know reflection is an option but thought spring may have a way to see the services provided by @Controller and allow me to display them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的
DispatcherServlet
使用的HandlerMapping
接口的具体实现,您也许能够从那里弄清楚。例如,如果您使用的是
SimpleUrlHandlerMapping
,则存在一个名为getUrlMap()
,返回一个地图url 路径映射。Depending on the specific implementation of the
HandlerMapping
interface that yourDispatcherServlet
is using, you may be able to figure it out from there.For example, if you are using the
SimpleUrlHandlerMapping
, there is a method present calledgetUrlMap()
, which returns a map of the url path mappings.尼古拉斯指出的是,映射请求有不同的方法。您必须检查您正在使用哪个 HandlerMapping ,然后了解如何通过类 getter 获取它存储的映射信息。
这是 Spring MVC 3.1 @Controllers 的示例:
https://github.com/rstoyanchev/spring-mvc-31-demo/tree/master/src/main/java/org/springframework/samples/mvc31/endpointdoc
What nicholas is pointing out is that there are different ways to maps requests. You've to check which HandlerMapping you're using exactly and then see how to get the mapping information it stores via class getters.
Here is an example for Spring MVC 3.1 @Controllers:
https://github.com/rstoyanchev/spring-mvc-31-demo/tree/master/src/main/java/org/springframework/samples/mvc31/endpointdoc