Files
Hui-s-notebook/logseq-java/pages/ThreadLocal使用场景.md
2024-02-02 00:12:49 +08:00

7 lines
413 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- 代替参数的显示传递
- 不需要在Controller,Service,Dao层之间传递直接从ThreadLoacal取数据
- 全局存储用户信息
- 用户信息存储SessionToken
- 拦截器获取用户信息后存储到ThreadLoacal中再从中获取
- 解决线程安全问题
- Dao,Connetinon只有一个有线程使用Connection时可以从ThreadLoacal中获取Connection没有就创建并存入