在app.xml中要加入aop的命名空间,看
http://static.springsource.org/spring/docs/2.0.x/reference/aop.html#aop-ataspectj
然后开启aop
<aop:aspectj-autoproxy />
在定义AOP的类中,要写@Aspect,表示这是个切面
还要加上@Component,让此aop交给Spring 管理
1、
@Pointcut("execution(* com.mhm.mng.impl..*.*(..))")
第一个*表示 返回类型
如果写成java.lang.String 则表示只对com.mhm.mng.impl 下的类以及子包下的类和方法进行拦截
*.*表示 类下面的方法
(..)表示方法中的参数随意
2、
com.mhm.mng.impl..*(..)
表示对com.mhm.mng.impl下的类以及子包下的类进行拦截
3、
com.mhm.mng.impl.PersonalMngimpl.*(..)
表示对表示对com.mhm.mng.impl下的PersonalMngimpl的所有方法进行拦截
4、
方法参数:
@Pointcut("execution(* com.mhm.mng.impl..*.*(java.lang.String, ..))")
表示如果方法第一个参数为String类型,第二个参数可有可无
5、拦截所有的返回值不是
@Pointcut("execution(!void com.mhm.mng.impl..*.*(java.lang.String, ..))")