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
GET|POST|DELETE|...
)Having access to this information where I could create a JSP view would be ideal.
In Spring MVC, controller methods are the final destination point that a web request can reach. After being invoked, the controller method starts to process the web request by interacting with the service layer to complete the work that needs to be done.
The controller returns an object of ModelAndView. The DispatcherServlet checks the entry of view resolver in the XML file and invokes the specified view component.
The @Controller annotation indicates that a particular class serves the role of a controller. Spring Controller annotation is typically used in combination with annotated handler methods based on the @RequestMapping annotation. It can be applied to classes only. It's used to mark a class as a web request handler.
@Controller annotation indicates that the annotated class is a controller. It is a specialization of @Component and is autodetected through classpath scanning. It is typically used in combination with annotated handler methods based on the @RequestMapping annotation.
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.
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.
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