81,094
社区成员
public static Class configClass(Class c, Map<String, ModelAttribute> attributeMap) {
Field[] fields = c.getDeclaredFields();
try {
for (int i = 0; i < fields.length; i++) {
Field f = fields[i];
String attributeName = f.getName();
if (attributeName.startsWith("param_")) {
if (attributeMap.containsKey(attributeName)) {
String attributeLable = attributeMap.get(attributeName).getAttributeLabel();
Excel excelAn = f.getAnnotation(Excel.class);//Excel是注解类型
if (excelAn == null) {
continue;
}
InvocationHandler h = Proxy.getInvocationHandler(excelAn);
Field hField = h.getClass().getDeclaredField("memberValues");
// 因为这个字段是 private 修饰,所以要打开权限
hField.setAccessible(true);
// 获取 memberValues
Map memberValues = (Map) hField.get(h);
// 修改 value 属性值 这里修改的是@Excel(name = "姓名")
//name是key
memberValues.put("name", attributeLable);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return c;
}
怎么解决的了?我这边也是这个需求
ruoyi