login intercepter do not work in spring -


all. using spring4 in project. , add , interceptor extends handlerinterceptoradapter, overwrite prehandle method. found not work when doing spring mock test. have configure in springmvc-servlet.xml , this:

    <mvc:interceptors>     <mvc:interceptor>         <mvc:mapping path="/**"/>         <bean class="com.suerpay.common.interceptor.logininterceptor"/>     </mvc:interceptor> </mvc:interceptors> 

and here code of logininteceptor:

public class logininterceptor extends handlerinterceptoradapter { @autowired loginserviceredis loginserviceredis; @autowired userservicedb userservicedb; logger logger = loggerfactory.getlogger(getclass());  public boolean prehandle(httpservletrequest request, httpservletresponse response, object handler) {     logger.info("start login interceptor");     if (isloginrequired(handler)) {         string ticket = request.getheader(globalconstants.ticket_header);         if (stringutils.isempty(ticket)) {             throw new unauthorizedexception(resultcodeconstants.user_not_login);         }         string username = loginserviceredis.getusernamebyticket(ticket);         long userid = userservicedb.getuseridbyname(username);         if (null == userid) {             throw new         unauthorizedexception(resultcodeconstants.user_not_login);         }         threadcontextholder.setcurrentuserid(userid);     }     logger.info("finish login interceptor");     return true; }  private boolean isloginrequired(object handler) {     handlermethod handlermethod = (handlermethod) handler;     method method = handlermethod.getmethod();     loginrequired loginrequired = method.getannotation(loginrequired.class);     if (null != loginrequired) {         return true;     }     return false; } 

}

i think have , can not breakpoint. can tell me why?:(


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -