gpt4 book ai didi

java - 在 Controller 中获取 Spring boot/security 的 session token

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:40:26 26 4
gpt4 key购买 nike

我们正在使用带有 spring security 的 spring boot 来实现一个查询接口(interface)。我想要做的是只允许每个用户一次运​​行固定数量的查询。查询可能需要很长时间,用户发送重复请求的速度可能快于我们的响应速度。我希望 Controller 一次只计算一个子集请求,并且我必须实现一些逻辑来确定要响应哪些请求。

为此,我需要知道给定用户的 session token 。有没有一种简单的方法可以在 Controller 的方法中获取它?

最佳答案

如果你想在 Controller 中获取 sessionId,你可以使用RequestContextHolder.currentRequestAttributes().getSessionId();

关于java - 在 Controller 中获取 Spring boot/security 的 session token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34072443/

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