日期:2014-05-20 浏览次数:20968 次
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 配置接口UserServer -->
<bean id="UserServer" class="com.feng.aop.UserServerImpl"></bean>
<!-- 配置关注点 -->
<bean id="SecurtyHandler" class="com.feng.aop.SecurtyHandler"></bean>
<!-- AOP的配置 -->
<aop:config>
<!-- 切点的配置,当切点位于方面外时,此切点可以被所有的方面所共享 -->
<aop:pointcut id="del"
<!-- 切点表达式,用于配对连接点(方法)是否符合表达式的定义 -->
<!-- 第一个*表示方法的返回值,del*表示配对以del开头的所有方法,最后..表示方法的参数可以为任意类型 -->
expression="execution(*
com.feng.aop.UserServerImpl.del*(..))" />
<!-- 方面配置,一个方面用于处理相同类型的功能的模块 -->
<aop:aspect id="allMethod" ref="SecurtyHandler">
<aop:pointcut id="query"
expression="execution(* com.feng.aop.UserServerImpl.query*(..))" />
<!-- 通知的使用,当某个切点的表达式成立时,即调用此通知注入的方法 -->
<aop:before method="check" pointcut-ref="query" />
<aop:before method="check" pointcut-ref="del" />
</aop:aspect>
</aop:config>
</beans>
------解决方案--------------------
具体写法参考
http://blog.csdn.net/luohuijun619/article/details/4988679