aop:config
/aop:aspect
/aop:config
advisor类
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
/**
@author seeblack
2015-12-20 下午3:44:55
*/
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);
}
}
advisor可以启动加载好
但是为什么**Action**类中方法执行的时候不会受到拦截,也就是不会进入到**before**等方法类
配置没发好,可以参考下这里
http://blog.csdn.net/evankaka/article/details/45241863
http://blog.csdn.net/evankaka/article/details/45394409
**
aop:config
/aop:aspect
/aop:config **
<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>