title: Class Cast Exception in HandlerMethod Spring mvc
body: <p>I want to create custom annotation that modify request. so create this annotation. </p>
  
  <pre><code>@Target(ElementType.METHOD)
  @Retention(RetentionPolicy.RUNTIME)
  public @interface MyAnnotation {
   boolean test() default true;
  }
  </code></pre>
  
  <p>and also MyInceptor class that extend from HandlerInterceptorAdapter. now in preHndler method in this class i want to cast handler to HandlerMethod. but an exception appear.for this exception i put a condition "if (handler instanceof HandlerMethod)" but handler not cast to handler method atall.
  How hanle this problem? </p>
  
  <pre><code>public boolean preHandle(HttpServletRequest request,
                           HttpServletResponse response, Object handler)
          throws Exception {
      MyAnnotation myAnnotation = null;
      if (handler instanceof HandlerMethod) {
          HandlerMethod handlerMethod = (HandlerMethod ) handler;
         //other 
      }
  }
  </code></pre>
  
  <p>Update 
  this exception occur. </p>
  
  <pre><code>       java.lang.ClassCastException: org.springframework.web.servlet.mvc.ParameterizableViewController cannot be cast to org.springframework.web.method.HandlerMethod
  </code></pre>