自定义拦截器(二)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package cn.itcast.crm.interceptor;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
public class extends MethodFilterInterceptor {
protected String doIntercept(ActionInvocation invocation) throws Exception {
Object user = ServletActionContext.getRequest().getSession().getAttribute("user");
if(user!=null){
invocation.invoke(); //直接放过
}
return "login";
}
}