阅读背景:

Struts2的拦截器只允许有权限用户访问action

来源:互联网 

1、定义拦截器,继承MethodFilterInterceptor 

package com.life.stuts.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;

/**
 * 如果不是login的adction,使用自定义拦截器判断用户是否为空。为空,跳转到登陆页面;否则,继续执行。
 * 在配置拦截器属性excludeMethods、includeMethods进行方法过滤时发现不起作用。
 * 要想使方法过滤配置起作用,拦截器需要继承MethodFilterInterceptor类。
 * MethodFilterInterceptor类是AbstractInterceptor的子类
 * @author JL
 * 
 */

public class SellerInterceptor extends MethodFilterInterceptor {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    @Override
    protected String doIntercept(ActionInvocation invocation) throws Exception {
        // TODO Auto-generated method stub
        Mappackag



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: