Class<?> aClass = xxx实体类.getClass();
        //得到属性
        Field field = null;
        try {
            field = aClass.getDeclaredField("字段名xxxx");
            //打开私有访问
            field.setAccessible(true);
            //获取属性
            String name = field.getName();
            //获取属性值
            String subjectType = (String) field.get(xxx实体类);
            System.out.println(subjectType);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-27
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-01-17
相关资源
相似解决方案