package com.tq365.util;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.tq365.vo.User;
/**
* 自定义的拦截器(放行登录操作和已经登录用户的操作)
* @author archie2010
*
*/
public class LoginInterceptor extends AbstractInterceptor{
private static final long serialVersionUID = 1406123004582563032L;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = ServletActionContext.getRequest().getSession();
User user = (User)session.getAttribute("USER");
// 请求的url
String path = request.getServletPath();
boolean flag = false;
if("/loginuser.jspx".equals(path)){
flag = true;
}else{
if(user!=null){
flag = true;
}
}
System.out.println(path);
return flag ? invocation.invoke() : "error";
}
}
<interceptors> <!-- login拦截器 --> <interceptor name="login" class="com.tq365.util.LongInterceptor"/> <interceptor-stack name="myInterceptor"> <interceptor-ref name="login"/> <interceptor-ref name="paramsPrepareParamsStack"/> </interceptor-stack> </interceptors> <default-interceptor-ref name="myInterceptor"/>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有