Package cn.iver.interceptor

Source Code of cn.iver.interceptor.LoginInterceptor

package cn.iver.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

/**
* Created with IntelliJ IDEA.
* Author: StevenChow
* Date: 13-5-7
*/
public class LoginInterceptor implements Interceptor {
    @Override
    public void intercept(ActionInvocation ai) {
        Controller controller = ai.getController();
        if(controller.getSessionAttr("user") != null){
            ai.invoke();
        }else{
            controller.setAttr("msg", "需要登录才可以进行改操作:)");
            controller.render("/user/login.html");
        }
    }
}
TOP

Related Classes of cn.iver.interceptor.LoginInterceptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.