这是我applicationCotext.xml中的配置文件
aop:config
/aop:aspect
/aop:config
这是我的advices类
public class Advisor {
static Logger log = Logger.getLogger(Advisor.class);
public String information;
/**
*
*/
public Advisor() {
// TODO Auto-generated constructor stub
log.info("进入");
}
public void before(JoinPoint joinpoint){
information = "通知:"+joinpoint.getClass().getName()+"类的"+joinpoint.getClass().getMethods()+"开始执行";
log.info(information);
}
public void after(JoinPoint joinpoint){
information = "通知:"+joinpoint.getClass().getName()+"类的"+joinpoint.getClass().getMethods()+"执行完毕";
log.info(information);
}
public void exception(JoinPoint joinpoint){
information = "通知:"+joinpoint.getClass().getName()+"类的"+joinpoint.getClass().getMethods()+"出现异常";
log.info(information);
}
}
<!--将日志类注入到bean中。-->
<bean id="advices" class="com.sunyard.advice.Advisor"></bean>
<aop:config>
<aop:aspect id="log" ref="advices">
<aop:pointcut id="pointcut" expression="execution(* com.sunyard.cpjbxxShow.action.*.*(..))"/>
<aop:before pointcut-ref="pointcut" method="before"/>
<aop:after pointcut-ref="pointcut" method="after"/>
<aop:after-throwing pointcut-ref="pointcut" method="exception"/>
</aop:aspect>
</aop:config>
不知道你是怎么调用的,,,