@Order(5) @Aspect @Component public class AnnotationInterceptor { private static Logger logger = LogManager.getLogger(AnnotationInterceptor.class.getName()); @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) || @annotation(org.springframework.web.bind.annotation.GetMapping) || " + "@annotation(org.springframework.web.bind.annotation.PostMapping) || @annotation(org.springframework.web.bind.annotation.PutMapping) || @annotation(org.springframework.web.bind.annotation.DeleteMapping)") public void RequestMapping() { } @Around("RequestMapping()") public Object Interceptor(ProceedingJoinPoint joinPoint) throws Throwable { RequestAttributes ra = RequestContextHolder.getRequestAttributes(); ServletRequestAttributes sra = (ServletRequestAttributes) ra; HttpServletRequest request = sra.getRequest(); // String tok
springboot请求url日志记录
最新推荐文章于 2024-08-09 15:28:36 发布
该博客介绍了如何使用Spring AOP创建一个注解拦截器,记录带有@RequestMapping、@GetMapping、@PostMapping、@PutMapping和@DeleteMapping注解的请求URL日志。拦截器不仅获取并记录了IP地址和请求参数,还包含了一个未实现的功能,即检查请求头中的token有效性。
摘要由CSDN通过智能技术生成