如何快速通過url定位到controller中的方法(採用AOP)
阿新 • • 發佈:2018-12-21
aspect 攔截controller顯示指明
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; import java.lang.reflect.Modifier; /** * */ @Component @Aspect public class HttpRequestAspect { @Pointcut("execution(* com.hikvision..*.controller..*.*(..))") public void httpRequestLog() {} @Around("httpRequestLog()") public Object around(ProceedingJoinPoint joinPoint) throws Throwable { Object data = joinPoint.proceed(joinPoint.getArgs()); System.out.println("目標方法名為:" + joinPoint.getSignature().getName()); System.out.println("目標方法所屬類的簡單類名:" + joinPoint.getSignature().getDeclaringType().getSimpleName()); System.out.println("目標方法所屬類的類名:" + joinPoint.getSignature().getDeclaringTypeName()); System.out.println("目標方法宣告型別:" + Modifier.toString(joinPoint.getSignature().getModifiers())); return data; } }