标签:
工具类代码
@Controller public class EndpointDocController { private final RequestMappingHandlerMapping handlerMapping; @Autowired public EndpointDocController(RequestMappingHandlerMapping handlerMapping) { this.handlerMapping = handlerMapping; } @RequestMapping(value="/endpointdoc", method= RequestMethod.GET) public String show(Model model) { model.addAttribute("handlerMethods", this.handlerMapping.getHandlerMethods()); return "endpointList"; } }
独立的controller使用。
endpointList.jsp代码如下:
<body> <h1>Endpoints list</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> </c:forEach> </body>
效果:
这样的话,很方便的找出url对应的处理器,希望对你有用
标签:
原文地址:http://my.oschina.net/lianlupeng/blog/416919