【发布时间】:2015-05-01 15:51:38
【问题描述】:
有没有办法让 BeanUtils 与 protected setXXX(X x) 方法一起工作?或者您知道其他方法吗?
类似:
public class A{
private String text;
public String getText(){
return this.text;
}
protected void setText(String text){
this.text = text;
}
}
public class B{
private String text;
public String getText(){
return this.text;
}
protected void setText(String text){
this.text = text;
}
}
public static void main(String[] args){
A a = new A();
a.setText("A text");
B b = new B();
BeanUtils.copyProperties(b, a);
System.out.println(b.getText()); //A text
}
【问题讨论】:
标签: java copy javabeans apache-commons-beanutils