我希望能够创建一个页面,列出由使用 @Controller
注释的控制器发现的映射。我这样做是为了 REST 服务,它使我们能够轻松找到页面上实例可用的端点。
到目前为止,我一直在手动执行此操作,但如果可以创建一个控制器,以一种令人愉快的格式很好地发布它,那将非常有益。
我需要的关键信息是
- 端点 URI
- 方法 (
GET|POST|DELETE|...
)
- 参数
- 标头
能够访问此信息并在其中创建 JSP 视图将是理想的选择。
I'd like to be able to create a page that lists off the mappings that were discovered by controllers annotated with @Controller
. I'm doing this for REST services that allows us to easily find the endpoints available to the instance on a page.
So far I've manually been doing this, though if it's possible to create a controller that publishes this in a pleasant format nicely it would be greatly beneficial.
Key information I'm after is
- Endpoint URI
- Method (
GET|POST|DELETE|...
)
- Params
- Headers
Having access to this information where I could create a JSP view would be ideal.
发布评论
评论(2)
在 Spring 3.1 中,有一个称为“端点文档”的新功能。我唯一能找到的是 spring-mvc-31-demo 示例应用程序中的一些代码< /a>.请参阅示例 控制器 和 JSP。看起来很简单。
With Spring 3.1, there is a new feature referred to as "end point documentation". The only thing I could find was some code in the spring-mvc-31-demo sample app. Refer to the example controller and JSP. Seems pretty straight forward.
查看此自定义 doclet https://github.com/rightshift/spring-mvc-api- doclet。它将为所有 Spring MVC @Controller 注解的类创建端点文档。可以创建自定义模板来生成不同的 HTML 输出。新模板名称只需作为可选参数传递。它还可以作为报告集添加到 Maven pom 的报告部分。
Check out this custom doclet https://github.com/rightshift/spring-mvc-api-doclet. It will create endpoint documentation for all Spring MVC @Controller annotated classes. Custom templates can be created to produce different HTML output. The new template name just needs to be passed as an optional param. It can also be added to as a reportSet to the reporting section of your maven pom.