Spring-AOP

1. 面向切面编程Aspect-Oriented-Programming            逻辑(添加源代码、继承、组合)

a) 是对面向对象的思维方式的有力补充

可用于  权限管理、日志、事物、异常管理

好处:可以动态的添加和删除在切面上的逻辑而不影响原来的执行代码

a) Filter

b) Struts2interceptor

概念:

a) JoinPoint

b) PointCut

c) Aspect(切面)

d) Advice

e) Target

f) Weave

Spring AOP配置与应用


1. 两种方式:

a) 使用Annotation

b) 使用xml

2. Annotation

a) 加上对应的xsd文件spring-aop.xsd

b) beans.xml <aop:aspectj-autoproxy />

c) 此时就可以解析对应的Annotation

d) 建立我们的拦截类

e) 用@Aspect注解这个类

f) 建立处理方法

g) 用@Before来注解方法

h) 写明白切入点(execution …….

i) 让spring对我们的拦截器类进行管理@Component


3. 常见的Annotation:

a) @Pointcut

b) @Before

c) @AfterReturning

d) @AfterThrowing

e) @After

f) @Around



4. 织入点语法

a) void !void

b) 参考文档(* ..



5. xml配置AOP

a) 把interceptor对象初始化

b) <aop:config

i. <aop:aspect …..

1. <aop:pointcut

2. <aop:before







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值