spring interceptor does not intercept method name Reason

Log on to develop an annotated interceptor, the interceptor can intercept encountered controller can not intercept the specific method name, so the interceptor completely useless, after careful exploration, DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter does not support the intercept method, we found that only 3.1 version after the support, but also need to use RequestMappingHandlerMapping and RequestMappingHandlerAdapter be replaced, it can be used directly by the introduction of annotation-driven, then you will find that the interceptor intercepts a method name, it can scan up to comment

 

What are the key changes from this revision information

After spring2.5
need to open and support @Controller @RequestMapping annotation processor by mapping DefaultAnnotationHandlerMapping processor and processor adapter AnnotationMethodHandlerAdapter.


Spring3.1 use
new HandlerMapping and HandlerAdapter to support @Contoller and @RequestMapping annotation processor.
New @Contoller @RequestMapping notes and supporting classes: mapping RequestMappingHandlerMapping processor and processor adapter RequestMappingHandlerAdapter combination instead of mapping DefaultAnnotationHandlerMapping processor and processor adapter AnnotationMethodHandlerAdapter Spring2.5 start providing more extension points.



In the spring mvc 3.1, the correspondence is changed to 
DefaultAnnotationHandlerMapping -> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping 
AnnotationMethodHandlerAdapter -> org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter 
AnnotationMethodHandlerExceptionResolver -> ExceptionHandlerExceptionResolver 


above are automatically registered after using annotation-driven

Guess you like

Origin www.cnblogs.com/zzt-lovelinlin/p/12076464.html