public class Person {
private String name;
private int age;
private Date birthday;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
Person p = new Person("ijunfu", 23);
BeanUtils.setProperty(p, "birthday.time", "111");
System.out.println(BeanUtils.getProperty(p, "birthday.time"));
}
}
为什么老是出现以下错误???
Exception in thread "main" java.lang.IllegalArgumentException: No bean specified
at org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:883)
at org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:935)
at org.apache.commons.beanutils.BeanUtils.setProperty(BeanUtils.java:456)
at com.ijunfu.study.java.enhance.day01.PersonTest.main(PersonTest.java:35)
public class Person {
private String name;
private int age;
private Date birthday = new Date();
public Person(String name, int age) {
this.name = name;
this.age = age;
}