zoukankan      html  css  js  c++  java
  • The FlexSession is invalid问题

    package com.cmbj.soa.servicemonitor.view.service.impl;
    
    import java.util.Enumeration;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    
    import flex.messaging.HttpFlexSession;
    import flex.messaging.MessageBrokerServlet;
    
    public class KMessageBrokerServlet extends MessageBrokerServlet {
    	@Override
    	public void service(HttpServletRequest req, HttpServletResponse res) { 
    		HttpSession httpSession = req.getSession(true);
    		HttpFlexSession flexSession = (HttpFlexSession)httpSession.getAttribute("__flexSession");
    		if( flexSession != null && !flexSession.isValid()){  
    			httpSession.removeAttribute("__flexSession");  
    		} 
    //		HttpSession httpSession = req.getSession(true);
    //		
    //		Enumeration<String> names = httpSession.getAttributeNames();
    //		String name = null;
    //		for (;  names.hasMoreElements();) {
    //			name = names.nextElement();
    //			if (httpSession.getAttribute(name) instanceof HttpFlexSession) {
    //				HttpFlexSession flexSession = (HttpFlexSession) httpSession.getAttribute(name);
    //				if(null != flexSession && !flexSession.isValid()){
    //					httpSession.setAttribute(name,null);
    //					httpSession.removeAttribute(name);
    //				}
    //				System.out.println("HttpFlexSession_name is " + name);
    //			}
    //		}
    		super.service(req, res);
    	}
    }
    


    重写MessageBrokerServlet的service方法,因为异常的源头来自该servlet用了一个invalid的HttpFlexSession去获取Principal,所以只要再service方法之前先判断下当前的HttpFlexSession是否已经无效,无效的话我们就从当前的HttpSession中移除这个无效的HttpFlexSession即可。这样,就能保证MessageBrokerServlet中所用的HttpFlexSession一定是有效的

  • 相关阅读:
    泛型
    Abp SSO
    Abp 添加权限项<一>
    自定义策略-简单实践 <一>
    RabbitMq 开始<一>
    Abp 领域事件简单实践 <四> 聚合根的领域事件
    Abp 领域事件简单实践 <三> 自定义事件
    1.CentOS7安装教程
    深入浅出JSONP--解决ajax跨域问题
    设置MySQL客户端连接使用的字符集
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3196670.html
Copyright © 2011-2022 走看看