<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency>
@RestController
public class MyController {
@RequestMapping(value="/hello", method=RequestMethod.GET)
public String hello() {
return "";
}
}
@Component
@Aspect
public class RequestInterceptor {
@Pointcut("execution(* com.example.controller.*.*(..))")
public void pointcut1() {}
@Before("pointcut1()")
public void doBefore() {
System.out.println("before");
}
@Around("pointcut1()")
public void around(ProceedingJoinPoint thisJoinPoint) throws Throwable {
System.out.println("around1");
thisJoinPoint.proceed();
System.out.println("around2");
}
@After("pointcut1()")
public void after(JoinPoint joinPoint) {
System.out.println("after");
}
@AfterReturning("pointcut1()")
public void afterReturning(JoinPoint joinPoint) {
System.out.println("afterReturning");
}
@AfterThrowing("pointcut1()")
public void afterThrowing(JoinPoint joinPoint) {
System.out.println("afterThrowing");
}
}
ServletRequestAttributes attributes =(ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest();
@After("pointcut1()")
public void after(JoinPoint joinPoint) {
logger.info("CLASS_METHOD : " + joinPoint.getSignature().getDeclaringTypeName()+ "." + joinPoint.getSignature().getName());
System.out.println("after");
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有