在java web编程中,经常使用shiro来管理session,也确实好用

  1. shiro来获取session的方式

SecurityUtils.getSubject().getSession()

其中SecurityUtils的getSubject代码如下

/**
* Returns the currently accessible {@code Subject} available to the calling code depending on
* runtime environment.
* <p/>
* This method is provided as a way of obtaining a {@code Subject} without having to resort to
* implementation-specific methods. It also allows the Shiro team to change the underlying implementation of
* this method in the future depending on requirements/updates without affecting your code that uses it.
*
* @return the currently accessible {@code Subject} accessible to the calling code.
* @throws IllegalStateException if no {@link Subject Subject} instance or
* {@link SecurityManager SecurityManager} instance is available with which to obtain
* a {@code Subject}, which which is considered an invalid application configuration
* - a Subject should <em>always</em> be available to the caller.
*/
public static Subject getSubject() {
Subject subject = ThreadContext.getSubject();
if (subject == null) {
subject = (new Subject.Builder()).buildSubject();
ThreadContext.bind(subject);
}
return subject;
}

  

Subject subject = ThreadContext.getSubject();

获取进程上下文,这个存在了问题,如果在使用线程池,获取的就是线程池里面的session,如果线程池为配置过期时间,那么线程池里面的线程一直不变,就会出现在线程池里面getsession就会是上一次的session,导致获取session失败

线程池原理可参考

https://www.cnblogs.com/ytxiao/articles/11081136.html

最新文章

  1. #听云博客大赛#如何在自己的App嵌入听云产品监控App性能
  2. 判断iframe是否加载完成的完美方法
  3. iOS时间问题
  4. web新内容
  5. zabbix问题处理
  6. WebBrowser打开Word文档的一些注意事项
  7. Async/Await FAQ
  8. [OpenCV] Samples 02: [ML] kmeans
  9. Scalaz(31)- Free :自由数据结构-算式和算法的关注分离
  10. Tiny Rss简明安装与配置笔记
  11. 在Sql Server 中使用正则表达式
  12. Android 百度地图定位(手动+自动) 安卓开发教程
  13. Linux下Weblogic域的创建过程
  14. bzoj1449————2016——3——14
  15. wkwebview加载本地html的要点
  16. 服务定位器(Service Locator)
  17. jackson使用问题:mapper.readValue()将JSON字符串转反序列化为对象失败或异常
  18. Jest &amp; React &amp; Enzyme
  19. tp框架中的一些疑点知识-8
  20. window上安装 MongoDB 及其 PHP扩展

热门文章

  1. 给postmessage加上callback方法
  2. js实现div转图片并保存
  3. net core体系-Xamarin-2概要(lignshi)
  4. Vector , list 和 deque的区别
  5. React中,input外边如果包一个div,可以把input的onChange事件绑定到div上面,并且也生效
  6. MongoDB divide 使用之mongotempalte divide
  7. Python与C/C++相互调用(转)
  8. Lab3 Report
  9. elasticsearch 数据备份
  10. Django学习:创建admin后台管理站点