haidaoxianzi 2010-09-13
spring-security模块实现了权限控制功能.
自定义过滤器
1.自定义一个类实现Interceptor接口.
2.配置在调用的action中.并且加入默认的过滤器栈.只要你要使用默认的过滤器栈.
<interceptors>
<interceptor name="auth" class="com.meiyoudao.filter.AuthFilter"></interceptor>
</interceptors>
<action name="welcome" class="com.meiyoudao.action.WelcomeAction">
<interceptor-ref name="auth"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
<result>/welcome.jsp</result>
</action>/**
*
*/
package com.meiyoudao.filter;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
/**
* @author meiyoudao
*
*/
public class AuthFilter implements Interceptor {
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#destroy()
*/
public void destroy() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#init()
*/
public void init() {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see com.opensymphony.xwork2.interceptor.Interceptor#intercept(com.opensymphony.xwork2.ActionInvocation)
*/
public String intercept(ActionInvocation invocation) throws Exception {
System.out.println("do something filter begin...");
String str = invocation.invoke();
System.out.println("do something filter end...");
return str;
}
}