Struts安全拦截器_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > Struts安全拦截器

Struts安全拦截器

 2012/5/10 10:41:10  扬起风帆  程序员俱乐部  我要评论(0)
  • 摘要:packageorg.hlc.server.interceptor;importjava.util.Map;importorg.apache.commons.logging.Log;importorg.apache.commons.logging.LogFactory;importcom.opensymphony.xwork2.ActionContext;importcom.opensymphony.xwork2.ActionInvocation;importcom.opensymphony
  • 标签:struts
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>

?

?

发表评论
用户名: 匿名