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");
}
}
}
}
项目:JFinal