开发者社区 问答 正文

-java,session销毁的问题 - java报错

登录成功后,return 完 就直接掉销毁session的方法了,都没回到页面,具体代码如下:

js:

 $.ajax({

          cache: true,

          type: "POST",

          url:'${ctx}/loginAction/login',

          data:'account='+account+'&password='+password,// 

          async: false,

          error: function(request) {

          

          //window.wxc.xcConfirm("网络错误", window.wxc.xcConfirm.typeEnum.info);  // "提示",

          },

          success: function(data) {

          if(data.success==true||data.msg=="relogin"){

          alert(111)

          window.top.location.href ="${ctx}/personal";

          }else{

          //window.wxc.xcConfirm(data.msg, window.wxc.xcConfirm.typeEnum.info);

          }

          }

      });

session销毁:

/**

* 每个浏览器访问结束超时的时候,服务器会销毁相应的HttpSession对象,

* 并触发HttpSession销毁事件,同时调用所注册HttpSessionListener事件监听器的sessionDestroyed方法

*/

@Override

public void sessionDestroyed(HttpSessionEvent event) {

System.out.println(DateUtil.getCrruentTime()+" 销毁sessionId=="+event.getSession().getId());

if (loginMap.containsValue(event.getSession())) {

User userinfo = (User)event.getSession().getAttribute(Constants.LOGIN_INFO_SESSION);

loginMap.remove(userinfo.getUserId());

event.getSession().setAttribute(Constants.LOGINOUT_TYPE, 0);//登录超时

}

if(sessionMap.containsKey(event.getSession().getId())){

sessionMap.remove(event.getSession().getId());

}

}

监听配置:

 <listener>

    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

  </listener>

  <listener>

    <listener-class>com.zyj.listener.MySessionListener</listener-class>

  </listener>


麻烦知道的提供点思路,我排查不出来,不懂为什么return后 直接就调销毁session的方法了,求教!!!

展开
收起
montos 2020-05-30 23:50:56 499 分享 版权
1 条回答
写回答
取消 提交回答
  • 有个过滤器,去销毁了!!!

    2020-05-30 23:51:05
    赞同 展开评论