codecamp

2.5 configInterceptor (Interceptors me)

此方法用来配置 JFinal  的全局拦截器,全局拦截器将拦截所有 action  请求,除非使用@Clear 在 Controller 中清除,如下代码配置了名为 AuthInterceptor 的拦截器。


public void configInterceptor(Interceptorsme)

 { me.add(newAuthInterceptor());

}


JFinal 的 Interceptor 非常类似于 Struts2,但使用起来更方便,Interceptor 配置粒度分为 Global、Class、Method 三个层次,其中以上代码配置粒度为全局。Class 与 Method 级的 Interceptor 配置将在后续章节中详细介绍。

2.4 configPlugin (Plugins me)
2.6 configHandler (Handlers me)
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

第十一章 JFinal 架构及扩展

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }