【问题标题】:Get the name of the "method argument" in aspect ? (AspectJ)获取方面的“方法参数”的名称? (方面J)
【发布时间】:2017-12-27 06:46:30
【问题描述】:
如何获取方面的参数名称,例如,如果我的方法是 test(Sample sampleDto),我需要知道我的方面的 sampleDto 的名称。如何从 ProceedingJoinPoint 得到它?
我试试这个,但我得到了空值。
String[] argumentsName = ((MethodSignature) proceedingJoinPoint.getSignature()).getParameterNames()
【问题讨论】:
标签:
aspectj
aspect
spring-aspects
【解决方案1】:
刚刚试了一下,效果很好
Reporter.log(gson.toJson(((MethodSignature) jp.getSignature()).getParameterNames()), true);
Reporter.log(gson.toJson(jp.getArgs()), true);
输出
[
"externalOrderId",
"tenderDto",
"checksum",
"cookieToken"
]
[
"C605600399",
{
"number": "XXXXXXXXXXXXXXXX",
"expiration": "XXXXXX",
"pin": "XXX",
"type": "CREDITCARD"
},
1514412484857,
"50113963101%2CP08rS1wzJiYqQEA3ODEkQVZWLy8sTksmMyNPJH4mXj0jQi1KOThfTld%2BQCQh"
]