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的拦截器功能来实现各种需求。