注释拦截器中HandlerMethod的问题

时间:2013-05-31 15:55:46

标签: java spring-mvc

public class AnnotationInterceptor extends HandlerInterceptorAdapter implements InitializingBean {
 public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HandlerMethod method = (HandlerMethod) handler;
        Api methodAnnotation = method.getMethodAnnotation(Api.class);

        if (methodAnnotation != null) {
            //..
        }
    }
}

给我:'HandlerMethod cannot be resolved to a type'

无法追踪任何有关原因的读物。

1 个答案:

答案 0 :(得分:1)

添加以下导入:

import org.springframework.web.method.HandlerMethod;