package org.hlc.server.interceptor; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; public class SecurityInterceptor implements Interceptor { private static final long serialVersionUID = -5791221564564552124539L; private static final Log log = LogFactory.getLog(SecurityInterceptor.class); public void destroy() { } public void init() { } @SuppressWarnings("unchecked") public String intercept(ActionInvocation invocation) throws Exception { //Action上下文 ActionContext actionContext = invocation.getInvocationContext(); //action名称 String actionName = actionContext.getName(); //Seession Map Map session = actionContext.getSession(); //做一些验证处理 //...... } }
<package name="default" extends="json-default"> <interceptors> <interceptor name="security" class="SecurityInterceptor"/> <interceptor-stack name="defaultStackWithExceptionAndSecurity"> <interceptor-ref name="defaultStack"/> <interceptor-ref name="security"/> </interceptor-stack> </interceptors> <default-interceptor-ref name="defaultStackWithExceptionAndSecurity"/> </package>
?
?