Class<?> cls = bean.getClass();
Field field = cls.getField(fieldName);
if (field == null) {
return null;
}[enter image description here][1]
field.setAccessible(true);
return (Integer) field.get(bean);
For example, if a and b, c and d inherit from F, F has public String name = 'sun', and when I get it, only a and b get this name, c and d get null. Why? I'm sure I inherited all the F
My current solution is to add static before name, but I don't know the principle, so I hope there is a solution
Aucun commentaire:
Enregistrer un commentaire