1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| @Test
public void test2() throws Exception{ Person p=new Person(); PropertyDescriptor decriptor = new PropertyDescriptor("username",Person.class); Method method=decriptor.getWriteMethod(); method.invoke(p, "张三");
method=decriptor.getReadMethod(); String username= (String) method.invoke(p); System.out.println(username); }
|