import java.lang.reflect.Field;
import org.apache.commons.beanutils.BeanUtils;
..
..

public String intercept(ActionInvocation invocation) throws Exception {
    	log.info("---------- 파라미터 Bean에 셋팅 ----------");

    	Object action = invocation.getAction();

    	Field fs [] = action.getClass().getDeclaredFields();
    	for( Field f : fs ){
    		if( f.getName().indexOf("Bean") > 0 ){
    			String s [] = StringUtils.split(f.toString(), " ");
    			if( s.length == 3 ){
	    			Class cls = Class.forName(s[1]);
	    			Object obj = cls.newInstance();
	    			BeanUtils.copyProperties(obj, ServletActionContext.getRequest().getParameterMap());
	    	    	f.setAccessible(true);
	    	    	f.set(action, obj);
    			}
    		}
    	}
    	return invocation.invoke();
    }

+ Recent posts