张慧的博客

张慧的博客

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  45 Posts :: 0 Stories :: 24 Comments :: 0 Trackbacks
所有的Form表单提交会先检查session的情况,使用一个单独的同步请求,session过期返回expired,否则返回alive,前端JS判断如果过期打开新窗口登录。   

jQuery(function($) {
    // action listener for form commit
    $("form").unbind("submit").submit(checkSession);

    $(document).ajaxComplete(function() {
        $("form").unbind("submit").submit(checkSession);
    });
});

function checkSession(event) {
    var checkSession;
    jQuery.ajax({
        url : sessionCheckServletPath, 
        data : {
            checkSession : true
        },
        async : false,
        complete: function (xhr, textStatus) {
            checkSession = xhr.getResponseHeader("sessionStatus");
        }
    });
    if ("expired" == checkSession) {
        window.open(ssoLoginUrl, "loginWindow");
        return false;
    }
    return true;
}
posted on 2012-07-18 21:23 张慧 阅读(1554) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: