1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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