⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 parameterinterceptor.java

📁 javaBB,一套很不錯的JSP源碼,特共享給大家
💻 JAVA
字号:
package org.javabb.interceptor;

import java.util.Iterator;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.Interceptor;

/*
 * Copyright 2004 JavaFree.org
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * $Id: ParameterInterceptor.java,v 1.3.8.2 2006/04/17 17:47:08 daltoncamargo Exp $
 * @author Ronald Tetsuo Miura
 */
public class ParameterInterceptor implements Interceptor {

    String allowedBeans = "";

    /**
     * @param allowedBeans
     */
    public void setAllowedBeans(String[] allowedBeans) {
        this.allowedBeans = StringUtils.join(allowedBeans, '|');
    }

    /**
     * @see com.opensymphony.xwork.interceptor.Interceptor#intercept(com.opensymphony.xwork.ActionInvocation)
     */
    public String intercept(ActionInvocation invocation) throws Exception {
        String regex = "^(?:" + allowedBeans + ")?\\.?[^.]*$";

        Map parameters = ActionContext.getContext().getParameters();
        Iterator it = parameters.keySet().iterator();
        while (it.hasNext()) {
            String param = (String) it.next();
            if (!param.matches(regex)) {
                it.remove();
            }
        }
        return invocation.invoke();
    }

    /**
     * @see com.opensymphony.xwork.interceptor.Interceptor#destroy()
     */
    public void destroy() {
        // TODO Auto-generated method stub
    }

    /**
     * @see com.opensymphony.xwork.interceptor.Interceptor#init()
     */
    public void init() {
        // TODO Auto-generated method stub
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -