Pre Merge pull request !573 from 啧啧/fix/excel-util-parent-field
This commit is contained in:
commit
2ba8c110ad
|
|
@ -1675,9 +1675,26 @@ public class ExcelUtil<T>
|
|||
if (StringUtils.isNotNull(o) && StringUtils.isNotEmpty(name))
|
||||
{
|
||||
Class<?> clazz = o.getClass();
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
o = field.get(o);
|
||||
Field field = null;
|
||||
for (; clazz != Object.class; clazz = clazz.getSuperclass())
|
||||
{
|
||||
try
|
||||
{
|
||||
field = clazz.getDeclaredField(name);
|
||||
break;
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (field != null)
|
||||
{
|
||||
field.setAccessible(true);
|
||||
o = field.get(o);
|
||||
} else
|
||||
{
|
||||
throw new NoSuchFieldException(name);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user