Spring Security封装threadLocal
时间: 2024-01-01 08:05:16 浏览: 112
Spring Security封装了ThreadLocal来保存SecurityContext。SecurityContextHolder是用来保存SecurityContext的类,而SecurityContext中包含了当前正在访问系统的用户的详细信息。默认情况下,SecurityContextHolder使用ThreadLocal来保存SecurityContext,这意味着在同一线程中的方法中,我们可以从ThreadLocal中获取当前的SecurityContext。Spring Security会在每次请求完成后自动清除当前线程的ThreadLocal,从而确保安全性。所以,Spring Security通过封装ThreadLocal来实现对SecurityContext的保存和管理。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [Spring Security详细讲解(JWT+SpringSecurity登入案例)](https://blog.csdn.net/weixin_42753193/article/details/126324474)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文