如何使用拦截器做一些事情

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD})
@Documented
public @interface CheckLogin {
}
@Slf4j
@Aspect
@Component
public class CheckLoginInterceptor {

    @Resource
    private LoginService loginService;

    @Pointcut("@annotation(CheckLogin)")
    public void annotationPointCut() {

    }

    @Around("annotationPointCut()")
    public Object doBeforeValidate(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {

      loginService.checkLogin();
    }

 

你可能感兴趣的:(Spring)