@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (this.logger.isDebugEnabled()) {
this.logger.debug(">>> handler: " + handler);
}
HandlerMethod handlerMethod = (HandlerMethod) handler;
Login login = handlerMethod.getMethod().getAnnotation(Login.class);
}
I had above interceptor code in spring 3.X that works.
I like to use this code in the Controller having @CrossOrigin
and @RequestMapping
method at spring boot 1.3.
but below error is occured.
How to get method information at Interceptor preHandle
method in spring boot 1.3?
Caused by: java.lang.ClassCastException: org.springframework.web.servlet.handler.AbstractHandlerMapping$PreFlightHandler cannot be cast to org.springframework.web.method.HandlerMethod
Is added to a portion to process the request CORS added after 4.2 Spring this will again process the "interceptor". So you can add code to check whether the "handler" of the object type "HandlerMethod" type.
e.g.
if (handler instanceof HandlerMethod) {...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With