try {
ExcelUtil<CustomUserDto> util = new ExcelUtil<CustomUserDto>(CustomUserDto.class);
Class<CustomUserDto> clazz = util.clazz;
Field field = clazz.getDeclaredField("deptName");
Excel annotation = field.getAnnotation(Excel.class);
InvocationHandler handler = Proxy.getInvocationHandler(annotation);
if (annotation != null) {
Field memberValues = handler.getClass().getDeclaredField("memberValues");
memberValues.setAccessible(true);
Map memberValuesMap = (Map) memberValues.get(handler);
memberValuesMap.put("combo", new String[]{"aa","bb","cc","dd","ee"});
String combo = annotation.combo()[4];
System.out.println(combo);
}
util.importTemplateExcel(response, "数据");
} catch (Exception e) {
throw new ServiceException("导出模板失败");
}
未经允许不得转载:
红吉他 »
JAVA »
使用反射改变注解的值