當前位置:編程學習大全網 - 網站源碼 - 各位大神,求救!!!java 如何獲取該類上字段的註解,看圖片

各位大神,求救!!!java 如何獲取該類上字段的註解,看圖片

我知道

1.先獲取這個類的class

Class<?> objclass=t.getClass();

2. 獲取這個類的字段屬性

Field[] at = objclass.getDeclaredFields();

3.遍歷所有字段

for (Field fd : at) {

//比如獲取這個字段上是否包含NotNull

if (fd.isAnnotationPresent(NotNull.class)) {

//這樣就獲取到這個註解屬性了

NotNull d = fd.getAnnotation(NotNull.class);

}

}

4.要獲取壹個註解,妳要先獲取他所在的字段

希望對妳有幫助!

  • 上一篇:5g最重要的性能指標是
  • 下一篇:idhttp1 在delphi7下如何設置代理IP和Port
  • copyright 2024編程學習大全網