-- JSP, SPRING
[spring] 선언한 모든 URI (RequestMapping) 표시하기
어린왕자악꿍
2017. 4. 3. 15:32
현재 SPRING 4.1을 사용 중에 모든 Controller에 선언한 RequestMapping (URI)를 표시해야 할 일이 생겼다.
아래의 예제에서는 GET방식의 URI만 표시하도록 하였다.
[TestController.java]
@Inject
private RequestMappingHandlerMapping endPoints;
@RequestMapping(value = "/test/list", method = RequestMethod.GET)
public String getEndPointsInView( Model model ) {
model.addAttribute("endPoints", endPoints.getHandlerMethods().keySet());
return "test/list";
}
[test/list.jsp]
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:forEach items="${endPoints}" var="endPoint">
<if test="${endPoint.methodsCondition eq '[GET]'}">
<c:set var="uri" value="${fn:replace(fn:replace(endPoint.patternsCondition, '[', ''), ']', '')}" />
<c:out value="${uri}" /><br>
</if>
</c:forEach>