Implementation of the HandlerMapping
interface that maps handlers based on HTTP paths expressed through the RequestMapping
annotation at the type or method level.
HandlerMapping 인터페이스의 구현은 타입 또는 메소드 레벨에서 RequestMapping 어노테이션을 통해 HTTP 경로를 기반으로 handler를 매핑한다.
Registered by default in DispatcherServlet
on Java 5+. NOTE: If you define custom HandlerMapping beans in your DispatcherServlet context, you need to add a DefaultAnnotationHandlerMapping bean explicitly, since custom HandlerMapping beans replace the default mapping strategies. Defining a DefaultAnnotationHandlerMapping also allows for registering custom interceptors
Java 5 이상에서 DispatcherServlet에 기본적으로 등록되어 있다.
NOTE: 커스텀 HandlerMapping bean을 DispatcherServlet 컨텍스트에 정의할 경우 DefaultAnnotationHandlerMapping bean 을 명시적으로 추가해주어야 한다. 커스텀 HandlerMapping bean이 기본 mapping을 대체하기 때문이다. DefaultAnnotationHandlerMapping 을 정의하면 사용자 정의 interceptor를 등록할 수 있다.
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
...
</property>
</bean>
Annotated controllers are usually marked with the Controller
stereotype at the type level. This is not strictly necessary when RequestMapping
is applied at the type level (since such a handler usually implements the Controller
interface). However, Controller
is required for detecting RequestMapping
annotations at the method level if RequestMapping
is not present at the type level.
annotiation이 달린 controller는 보통 타입 레벨에서 controller 스트레오타입으로 표시된다. RequestMapping이 타입 레벨에 적용될 때 (이러한 handler는 보통 Controller 인터페이스를 구현하므로) 반드시 필요한 것은 아니다. 그러나 Controller는 RequestMapping이 타입 레벨에 없는 경우 메소드 레벨에서 RequestMapping annotation을 감지하는데 필요하다.
The AnnotationMethodHandlerAdapter
is responsible for processing annotated handler methods, as mapped by this HandlerMapping. ForRequestMapping
at the type level, specific HandlerAdapters such as SimpleControllerHandlerAdapter
apply.
AnnotationMethodHandlerAdapter는 HandlerMapping에 의해 mapping된 annotated method를 처리한다. 타입 레벨의 RequestMapping의 경우 SimpleControllerHandlerAdapter 같은 특정 HandlerAdapter 가 적용된다.