public void configInterceptor(Interceptors me) {
me.add(new MyInterceptor());
}
@Before(MyInterceptor.class)
public class MyController extends Controller {
// controller logic
}
public class MyInterceptor implements Interceptor {
public void doIntercept(Invocation inv) {
// intercept logic
}
}
@Before(MyInterceptor.class)
public class MyController extends Controller {
// controller logic
}
@Before(AnotherInterceptor.class)
public class AnotherController extends Controller {
// controller logic
}
@ClearInterceptor(MyInterceptor.class)
public class MyController extends Controller {
// controller logic
}
public void configInterceptor(Interceptors me) {
me.addGlobalActionInterceptor(new GlobalInterceptor());
}
通過以上技巧,可以靈活地使用jfinal的攔截器功能來實現各種需求。