直接上代码。
ApplicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
theAdvice
拦截器类:
package com.gjf.interceptor;
import java.lang.reflect.Method;
import java.util.Arrays;
import org.springframework.aop.MethodBeforeAdvice;
public class MethodBeforeAdviceImpl implements MethodBeforeAdvice{
@Override
public void before(Method m, Object[] args, Object o)
throws Throwable {
System.out.println("运行前检查....");
System.out.println("method:" + m.getName());
System.out.println("args:" + Arrays.asList(args));
System.out.println("object:" + o);
}
}
我希望在执行service方法的时候,能够输出拦截器中before方法的内容,但是每次都直接输出service方法的结果?请帮我看看我的配置文件中是否存在问题,在线等。!!