日期:2014-05-20 浏览次数:20691 次
<interceptor name="checkPrivilege" class="cn.rayton.struts2.interceptor.CheckPrivilegeInterceptor"></interceptor>
<!-- 定义拦截器栈 -->
<interceptor-stack name="myStack">
<interceptor-ref name="checkPrivilege"></interceptor-ref>
<interceptor-ref name="paramsPrepareParamsStack"></interceptor-ref>
</interceptor-stack>
<!-- 配置默认要使用的拦截器栈,对本包中的Action都有效 -->
<default-interceptor-ref name="myStack"></default-interceptor-ref>
public class CheckPrivilegeInterceptor extends AbstractInterceptor {
private static final long serialVersionUID = 1L;
@Override
public String intercept(ActionInvocation invocation) throws Exception {
// 打印出类名
System.out.println("Action:"+invocation.getAction().getClass().getName());
//找到运行的ActionProxy对象,并打印其要运行的方法名
System.out.println("Method:"+invocation.getProxy().getMethod());
if (invocation.getAction() instanceof LoginLogoutAction) {
return invocation.invoke();
}
.........其他省略
}
}