gpt4 book ai didi

java - 主题 网络环境中的本地问题

转载 作者:行者123 更新时间:2023-11-30 04:29:37 26 4
gpt4 key购买 nike

我知道每个请求都由一个 servlet 线程提供服务,但是对于一个用户 session ,两个请求是否可以由两个不同的线程提供服务?

如果上述情况真的发生,那么第一个请求服务线程存储的线程局部变量被第二个请求服务线程读取怎么办?

我担心,如果我将用户凭据存储在第一个线程中的 Spring Security 的 SecurityContextHolder(使用线程局部变量)中,第二个线程将无法访问用户凭据...

最佳答案

I know that every request is served by a servlet thread, but will it be possible for one user session, two request served by two different thread?

是的,这是可能的。

I'm afraid that if I store user credential in Spring Security's SecurityContextHolder(which uses thread local variable) in first thread, the second thread will not be able to access the user credential...

Spring 为每个请求单独建立安全性,您不必自己处理。

关于java - 主题 网络环境中的本地问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14976049/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com