Spring MVC Annotations and HandleInterceptors -
I am on a project using Spring 3.x MVC, and have implemented our controller using annotations. We need to implement handler interactors recently, for which I had some problems. When I specify in my configuration ( Then all is well, i.e., any URL mail hits my interceptor code. When I Then I never hit Example dispatcher-sevlet.xml ), the interceptor
& lt; Bean id = "myInterceptor" class = "com.myProject.controllers MyInterceptor" /> & Lt; Bean id = "Handler mapping" category = "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" & gt; & Lt; Property Name = "Interceptor" & gt; & Lt; List & gt; & Lt; Ref bean = "myInterceptor" /> & Lt; / List & gt; & Lt; / Property & gt; & Lt; / Bean & gt;
& lt; Property Name = "Mapping" & gt; & Lt; Theater Content & gt; & Lt; Prop key = "/ addFile.request" & gt; MyFileController & lt; / Prop & gt; & Lt; / Theater & gt; & Lt; / Property & gt;
myInterceptor code ... I used the code mapping code using the
@RequestMapping annotation have tried.
& lt; Mvc: interceptors & gt; Tags are easy to use Interceptor if you are using annotation-based configurations.
& lt; Mvc: interceptors & gt; & Lt ;! - It all goes for mapping - & gt; & Lt; Bean class = "my.package.GlobalInterceptor" /> & Lt; MVC: Interceptor & gt; & Lt ;! - It runs only for a specific URL pattern - & gt; & Lt; Mvc: mapping path = "/ admin / *" /> & Lt; Bean class = "my.package.AdminInterceptor" /> & Lt; / MVC: Interceptor & gt; & Lt; / MVC: Interceptor & gt;
Comments
Post a Comment