java - Spring interceptor works with xml but not with config class -


im using interceptor configured xml :

<mvc:interceptors>     <bean class="org.resthub.dashboard.basicinterceptor" /> </mvc:interceptors> 

but put in config class :

    @configuration     @componentscan("org.resthub.dashboard")     @enablewebmvc     @enableaspectjautoproxy(proxytargetclass=true)     public class webappconfig extends webmvcconfigureradapter{          @override         public void addinterceptors(interceptorregistry registry) {             registry.addinterceptor(new basicinterceptor());         }          @bean         public internalresourceviewresolver setupviewresolver() {             internalresourceviewresolver resolver = new internalresourceviewresolver();             resolver.setprefix("/web-inf/views/");             resolver.setsuffix(".jsp");             return resolver;         }     } 

but doesn't work , don't know why. interceptor never called.

any ideas ?

thank you

edit : here basicinterceptor

    package org.resthub.dashboard;      import javax.servlet.http.httpservletrequest;     import javax.servlet.http.httpservletresponse;      import org.springframework.security.core.authentication;     import org.springframework.security.core.context.securitycontextholder;     import org.springframework.web.servlet.modelandview;     import org.springframework.web.servlet.handler.handlerinterceptoradapter;      public class basicinterceptor extends handlerinterceptoradapter {          @override         public void posthandle(httpservletrequest request,                 httpservletresponse response, object handler,                 modelandview modelandview) throws exception {             // todo auto-generated method stub             super.posthandle(request, response, handler, modelandview);              system.out.println("interceptororrr§§§§§§");             if (modelandview != null && modelandview.getmodelmap() != null) {     ...             }         }      } 

it seems configuration correct, @ least if have verified in fact picked up. however, problem happens during request causes posthandle not executed. make sure no execption thrown during request execution. , verify interceptor in fact used, can implement prehandle or aftercompletion , see if methods executed.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -