TestPropertyUtils

要导入beanutils.jar、logging.jar两个包

用来将获取的数据封装到javabean对应的属性中

public class TestPropertyUtils {
 @Test
 public void testPropertyUtils() throws Exception, InvocationTargetException, NoSuchMethodException{
  Customer customer = new Customer();
  PropertyUtils.setProperty(customer, "id", 5);
  PropertyUtils.setProperty(customer, "name", "shawn");
  PropertyUtils.setProperty(customer, "email", "[email protected]");
  PropertyUtils.setProperty(customer, "birth", new Date(new java.util.Date().getTime()));
  
  System.out.println(customer);
  
 }
}

你可能感兴趣的:(TestPropertyUtils)