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日