www.pudn.com > struts2.rar > AuthInterceptor.java, change:2009-08-19,size:575b


package com.test.interceptor; 
 
import java.util.Map; 
import com.opensymphony.xwork2.Action; 
import com.opensymphony.xwork2.ActionInvocation; 
import com.opensymphony.xwork2.interceptor.AbstractInterceptor; 
 
public class AuthInterceptor extends AbstractInterceptor { 
 
	public String intercept(ActionInvocation invocation) throws Exception { 
		// TODO Auto-generated method stub 
		 
		Map map = invocation.getInvocationContext().getSession(); 
		 
		if(map.get("user") == null) 
		{ 
			return Action.LOGIN; 
		}else 
		{ 
			return invocation.invoke(); 
		} 
	} 
}