@Aspect
@Component
public class ionImpAop { @Pointcut("@annotation(net.spring.intf.iocImp)")
public void ionImpMethod() {
} @Before("ionImpMethod()")
public void beforeMethod() {
System.out.println("before");
} @Around("ionImpMethod()")
public Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object object = null;
try {
object = proceedingJoinPoint.proceed();
} catch (Exception e) {
throw e;
}
System.out.println("around");
return object;
} @After("ionImpMethod()")
public void afterMethod() {
System.out.println("after");
}
}为什么 @Around 下面那个方法加上 throws Throwable @Before 跟原来调用service后面的方法能够执行
没加上 throws Throwable 这个的时候,只能进入到 @After 方法 ,@Before 方法不进,而且调用 service方法的后续代码也不执行
@Component
public class ionImpAop { @Pointcut("@annotation(net.spring.intf.iocImp)")
public void ionImpMethod() {
} @Before("ionImpMethod()")
public void beforeMethod() {
System.out.println("before");
} @Around("ionImpMethod()")
public Object aroundMethod(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
Object object = null;
try {
object = proceedingJoinPoint.proceed();
} catch (Exception e) {
throw e;
}
System.out.println("around");
return object;
} @After("ionImpMethod()")
public void afterMethod() {
System.out.println("after");
}
}为什么 @Around 下面那个方法加上 throws Throwable @Before 跟原来调用service后面的方法能够执行
没加上 throws Throwable 这个的时候,只能进入到 @After 方法 ,@Before 方法不进,而且调用 service方法的后续代码也不执行
解决方案 »
- Jsp脚本里方法定义的问题
- void launchFrame() 这个方法属于哪个类??作用?
- JSP文件上传!!
- JSF中如何给javaBean赋值
- 几天了..还没解决.Struts+spring+hibernate第一次使用报错...请大家指教..
- 有人用过Groovy吗?能否给个例子?xml-xml
- 我做的第一个hibernate映射,出错了,大家帮我看下,有详细的说明
- 急:用JAVA实现的socket通信中怎么实现HTTP协议的数据封装啊
- 一个关于EJB的remove方法的疑问??
- oracle数据库中,如果日期类数据为空,那得到的是什么数据!
- hibernate的Transformers使用问题
- Ajax和Servlet交互
public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {
Object object = null;
try {
object = joinPoint.proceed();
} catch (Exception e) {
throw e;
}
// net.spring.service.helloService@684c4676
Object tar = joinPoint.getTarget(); Object[] meth= joinPoint.getArgs(); // List net.spring.service.helloService.getList()
Signature signature = joinPoint.getSignature(); Object htis = joinPoint.getThis(); System.out.println("around");
return object;
}
我改成这样 Object[] meth= joinPoint.getArgs(); 为甚 meth 一直是空的,并没有前面调用的