以set方法为例子
String name = "QLC100";//属性的名字
String methodName = "set" +name .charAt(0) + name .substring(1);//拼接获取set方法
System.out.println(methodname);//setQLC100
Method method = clazz.getDeclaredMethod(methodname, QlcNodeVO .class); //
method.invoke(qlcNodeAllVO, qlcNodeVO); //回调赋值
public class QlcNodeAllVO {
private QlcNodeVO QLC100 ;
private QlcNodeVO QLC200 ;
public QlcNodeVO getQLC100() {
return QLC100;
}
public void setQLC100(QlcNodeVO QLC100) {
this.QLC100 = QLC100;
}
public QlcNodeVO getQLC200() {
return QLC200;
}
public void setQLC200(QlcNodeVO QLC200) {
this.QLC200 = QLC200;
}
}
public class QlcNodeVO {
private String name;//名称
private String code;//编码
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
}