可以借鉴:

https://www.cnblogs.com/zdj-/p/8665454.html

具体原因:Filter(过滤器),Interceptor(拦截器),无法对request请求的参数做处理以及控制器处理之后的response,所以切面出现.

步骤:

1.定义切面类 类上加上注解(@Aspect , @Compoent,@Configure)

2.类里面定义切点@Pointcut("

execution(* com.example.demo.controller.*.*(..))

"),里面指定所对应的切片类(一般为Controller类)。

 

3.定义通知类型

(1)@Before(""),前置通知---

可以对request请求做出处理,
通过JoinPoint 获取通知的签名信息,如目标方法名,目标方法参数信息等。
如:

 

(2)@After(""),后置通知---

处理完Controller请求之后的处理。

(3)@Around(""),环绕通知------最先执行的就是环绕通知,然后前置通知,最后后置通知。

    * 环绕通知非常强大,可以决定目标方法是否执行,什么时候执行,执行时是否需要替换方法参数,执行完毕是否需要替换返回值。
        环绕通知第一个参数必须是org.aspectj.lang.ProceedingJoinPoint类型
     */
    @Around("excuController()")//环绕通知 execution(com.example.demo.controller.*.*(..))
    public Object handlerController(ProceedingJoinPoint proceed)throws Throwable{
        System.out.println("切面开始。。。。。");
        System.out.println("环绕通知方法名:"+proceed.getSignature().getName());
        try{
            proceed.proceed();
        }catch (Exception e){
            e.printStackTrace();
        }
        return null;
    }

但是,在切面中我并没有感受到其带来的实际作用,因为都是viod方法........................这点后续再考虑下?????