23
我是一名新的Java程序員。以下是我的代碼:如何在java中獲取參數的註解?
public void testSimple1(String lotteryName,
int useFrequence,
Date validityBegin,
Date validityEnd,
LotteryPasswdEnum lotteryPasswd,
LotteryExamineEnum lotteryExamine,
LotteryCarriageEnum lotteryCarriage,
@TestMapping(key = "id", csvFile = "lottyScope.csv") xxxxxxxx lotteryScope,
@TestMapping(key = "id", csvFile = "lotteryUseCondition.csv") xxxxxxxx lotteryUseCondition,
@TestMapping(key = "id", csvFile = "lotteryFee.csv") xxxxxxxx lotteryFee)
我想要獲取所有字段的註釋。一些字段被註釋,而另一些不是。
我知道如何使用method.getParameterAnnotations()
函數,但它只返回三個註釋。
我不知道如何對應它們。
我期望以下結果:每參數
lotteryName - none
useFrequence- none
validityBegin -none
validityEnd -none
lotteryPasswd -none
lotteryExamine-none
lotteryCarriage-none
lotteryScope - @TestMapping(key = "id", csvFile = "lottyScope.csv")
lotteryUseCondition - @TestMapping(key = "id", csvFile = "lotteryUseCondition.csv")
lotteryFee - @TestMapping(key = "id", csvFile = "lotteryFee.csv")