The demonstration was for an Endpoint Controller - a page to display all the uri's supported by the application, their corresponding handler methods and related patterns(method, params etc).
The RequestMappingHandlerMapping component of Spring MVC maps the uri's to different @RequestMapped methods, and the demo item shows a way to expose these uri's and handler methods using a controller - the Endpoint documentation Controller, which looks like this:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
@Controller
public class EndpointDocController {
private final RequestMappingHandlerMapping handlerMapping;
@Autowired
public EndpointDocController(RequestMappingHandlerMapping handlerMapping) {
this.handlerMapping = handlerMapping;
}
@RequestMapping(value="/endpointdoc", method=RequestMethod.GET)
public void show(Model model) {
model.addAttribute("handlerMethods", this.handlerMapping.getHandlerMethods());
}
}
and a jsp page to display this information cleanly:
<div class="container">
<div class="container">
<h1>Spring MVC 3.1 Demo Endpoints</h1>
<c:forEach items="${handlerMethods}" var="entry">
<div>
<hr>
<p><strong>${entry.value}</strong></p>
</div>
<div class="span-3 colborder">
<p>
<span class="alt">Patterns:</span><br>
<c:if test="${not empty entry.key.patternsCondition.patterns}">
${entry.key.patternsCondition.patterns}
</c:if>
</p>
</div>
......
This would be something along the lines of what is displayed in the UI:
More information is available at the demo link and at Rossen Stoyanchev's github location: https://github.com/rstoyanchev/spring-mvc-31-demo.git



