public class Interceptor implements MethodBeforeAdvice{
public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
if(AA){ //终止以后的操作 }
else{}
}
}public class Test{
public void method(Object o){}
}<bean id="XXX"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref local="XX"/>
</property> <property name="interceptorNames">
<list>
<value>interceptor</value>
</list>
</property>
</bean>我定义了一个拦截器 Interceptor 对类 Test 的方法 method 拦截
判断method的参数 如果满足AA则终止 method方法 那要怎么才能终止他
我在(//终止以后的操作)抛出一个exception 如果在(//执行method)这里catch他会说
从未从try主体语句抛出此异常是不是不应该用exception终止操作public class XX{
public static void main(String[] args){
//执行method
}
}
public void before(Method arg0, Object[] arg1, Object arg2)
throws Throwable {
if(AA){ //终止以后的操作 }
else{}
}
}public class Test{
public void method(Object o){}
}<bean id="XXX"
class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<ref local="XX"/>
</property> <property name="interceptorNames">
<list>
<value>interceptor</value>
</list>
</property>
</bean>我定义了一个拦截器 Interceptor 对类 Test 的方法 method 拦截
判断method的参数 如果满足AA则终止 method方法 那要怎么才能终止他
我在(//终止以后的操作)抛出一个exception 如果在(//执行method)这里catch他会说
从未从try主体语句抛出此异常是不是不应该用exception终止操作public class XX{
public static void main(String[] args){
//执行method
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货