0
我正在使用Spring Boot開發REST API,並且我想記錄客戶使用Spring Aspect檢索的資源的URL。我的看點類有這樣的代碼:使用Spring AspectJ登錄REST資源URL
@Component
@Aspect
public class Logs {
@Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping)")
public void allResources() {}
@Before("allResources()")
public void apiRequestLog(JoinPoint jp) {
LogManager.getLogger(jp.getSignature().getDeclaringTypeName()).info("------------------------- o -------------------------");
String log = jp.getSignature().getName() + " >>>";
for (Object arg : jp.getArgs()) {
log += "\n ARG: " + arg;
}
LogManager.getLogger(jp.getSignature().getDeclaringTypeName()).info(log);
}
}
我不知道如何打發RequestMapping對象作爲參數的意見,並獲取URL路徑。