beanutils获取带参数get方法

public Employee getEmployee(int index) {
        return new Employee();
    }

1、PropertyUtils.getIndexedProperty带2个参数

  //    public static void main(String[] args) throws Exception {
//        Employee employee=new Employee();
//        int index=3;
//        String emp="employee["+index+"]";
//        //PropertyUtils.setIndexedProperty(employee, num, new Object[]{1,2,3});
//        Employee e=(Employee) PropertyUtils.getIndexedProperty(employee, emp);
//        System.out.println(e);
//    }

 

2、PropertyUtils.getIndexedProperty带3个参数

public static void main(String[] args) throws Exception {
        Employee employee=new Employee();
        int index=3;
        String emp="employee";
        Employee e=(Employee) PropertyUtils.getIndexedProperty(employee, emp,index);
        System.out.println(e);
    }

posted @ 2014-10-26 20:33  单方面  阅读(471)  评论(0编辑  收藏  举报