切面(个人理解):其实就是开发中对重复代码单独封装成的类,在使用时对需要加强的方法(该方法也就是切点)进行切割
ChineseSay.java
public class ChineseSay implements ISay {
@Override
public void say() {
// return "你好"; //返回的话会打乱aop拦截的顺序,最后才输出结果
System.out.println("你好");
}
}
EnglishSay.java
public class EnglishSay implements ISay {
@Override
public void say() {
System.out.println("hello");
}
}
InterceptSay.java
@Aspect //表明当前类是一个切面类
public class InterceptSay {
@Before("execution(* com.hand.sxt.Person.say(..))")
public void before(){
System.out.println("before+25527");
}
@After("execution(* com.hand.sxt.Person.say(..))")
public void after(){