这边我实现了Interceptor 为什么执行controller中的方法日志没有打印?

package com.roboy.Interceptor;


import javax.servlet.http.HttpSession;


import org.apache.log4j.Logger;


import com.jfinal.aop.Interceptor;

import com.jfinal.aop.Invocation;


public class MyInterceptor implements Interceptor{

Logger logger = Logger.getLogger(MyInterceptor.class);


@Override

public void intercept(Invocation in) {

logger.info("执行了该方法");

HttpSession session = in.getController().getSession();

if(session == null ){

in.getController().redirect("/login");

}

else{

String nickname = (String) session.getAttribute("username");

if(nickname != null ){

}else{

in.getController().redirect("/login");

}

}

}


}


评论区

caoxusheng

2017-06-27 10:12

在需要拦截的Controller上 加上@Before(MyInterceptor.class) 或者在configRoute里面 me.addInterceptor(interceptor);

热门反馈

扫码入社