首页>代码>SSH学生宿舍管理系统>/susheManage-master/src/com/business/action/LoginInterceptor.java
package com.business.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * 拦截器
 * @author Administrator
 *
 */
public class LoginInterceptor implements Interceptor {

	private static final long serialVersionUID = 1L;
	public static String loginPath = "loginPath";

	public void init() {
		// System.out.println("调用拦截器的init()方法");
	}

	public String intercept(ActionInvocation arg0) throws Exception {
		try {
			// System.out.println("------------调用拦截器的intercept方法开始-----------");
			Object obj = arg0.getAction();
			if (obj instanceof SystemManageAction) {
				// System.out.println("---可以正确登录系统---");
				return arg0.invoke(); // 去下一个拦截器
			}

			Map<?, ?> session = arg0.getInvocationContext().getSession();
			String loginId = (String) session.get("loginId");
			if (null != loginId && loginId.length() > 0) {
//				System.out.println("----" + loginId + "----已经登陆了---");
				return arg0.invoke();
			} else {
//				System.out.println("======没有登录====");
				return loginPath;
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return loginPath;
	}

	public void destroy() {
//		System.out.println("调用拦截器的destroy()方法");
	}

}
最近下载更多
Yht2219553  LV2 3月14日
张果  LV2 1月31日
958546428  LV3 2023年11月10日
kxjh星辰  LV6 2023年10月25日
shajunming  LV2 2023年10月20日
dev1ce123  LV4 2023年10月17日
微信网友_6184005683466240  LV11 2023年6月11日
星予宝藏666  LV6 2023年5月29日
asa566  LV10 2023年4月26日
朱朱啊哈  LV16 2023年2月2日
最近浏览更多
hhxq0902 4月20日
暂无贡献等级
qibodong  LV14 4月17日
dhcpsl  LV2 4月10日
Yht2219553  LV2 3月14日
quartz  LV7 3月13日
eam124  LV2 2月27日
FF加菲猫  LV4 2月14日
张果  LV2 1月31日
dht8904  LV1 1月24日
i-caigou 1月18日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友