登陆超时处理
2016-01-14 16:33
211 查看
捕获异常函数
jQuery.utilsAjaxException = { "ajaxException": function () { $(document).ajaxError(function (event, request, ajaxOptions, thrownError) { var str = 'timed_out_please_login'; if (request.responseText === str) { window.location.href = 'exitView.hd' } else if (request.responseText === "Permission denied.") { resultTips("非法操作!", false); } }); } } jQuery.checkSession = function () { $.post("checkSession.hd", { userId: $("#userSessionId").val() }, function (data) { if (data === "false") { window.location.href = 'exitView.hd'; } }); };
index.html
jQuery.checkSession(); //异常处理 jQuery.utilsAjaxException.ajaxException();
定义注解
@Target(ElementType.METHOD)//这个标注应用于方法 @Retention(RetentionPolicy.RUNTIME)//标注会一直保留到运行时 @Documented//将此注解包含在javadoc中 public @interface SessionControllerAnnotation { }
定义切点
/** * 系统切点类,定义系统级的切点, * */ @Aspect @org.springframework.stereotype.Component public class SystemAspect { public SystemAspect() { } /** * 方法执行前的处理 * * @param jp * @throws Exception */ @Before(value = "@annotation(com.ithings.wp.session.SessionControllerAnnotation)") public void beforeAspect(JoinPoint jp) throws Exception { UserDto user = null; for (Object param : jp.getArgs()) { if (param instanceof HttpServletRequest) { user = (UserDto) ((HttpServletRequest) param).getSession().getAttribute(SystemConstant.SESSION_USER); } } if (CommUtils.isNull(user)) { throw new Exception("<globalError>operation_timed_out_please_login_again<globalError>"); } } }
配置
<aop:aspectj-autoproxy proxy-target-class="true" />
相关文章推荐
- ios 栈区,堆区
- bootstrap零碎知识点
- 干货,pomelo路由解读
- ios Coredata 的 rollback undo 等事物处理函数
- Linux系统环境下关于多进程并发写同一个文件的讨论
- 选取图片裁剪并上传功能的实现(后台java实现)
- 五个例子掌握theano.scan函数
- android的消息处理机制(图+源码分析)——Looper,Handler,Message
- Webrtc Jitter Buffer
- android中小部件PopupWindow
- java实现给定字符串之间的全排列算法
- eclipse安装插件Properties Editor
- Java获取本地IP (windos平台、linux平台)
- UITabBar背景、icon图标颜色、被选中背景设置以及隐藏UITabBar的两种方式
- mac-文本编辑器
- __autoreleasing 以及OC错误模型 异常 错误 空返回
- FMDB(用SQLite存数据)
- JAVA中switch case 语句的用法
- fopen与open的区别
- android ndk编译,方法找不到,collect2: ld returned 1 exit status