小编fre*_*red的帖子

如何在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)
Run Code Online (Sandbox Code Playgroud)

我想获得所有提交的注释.有些字段是注释的,有些则不是.

我知道如何使用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 = …
Run Code Online (Sandbox Code Playgroud)

java reflection annotations

27
推荐指数
1
解决办法
3万
查看次数

标签 统计

annotations ×1

java ×1

reflection ×1