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(); }