gpt4 book ai didi

java - 在 Java Spring Boot 中从 Principal 中提取数据

转载 作者:行者123 更新时间:2023-12-04 10:02:33 26 4
gpt4 key购买 nike

我尝试从 Principal 中提取数据。

principal

怎么做?我需要来自“属性”集合的登录值。
校长没有这样的方法。

最佳答案

像这样的东西可以工作。获得这些属性总是有点讨厌。

    @RequestMapping("/user")
public void user(Authentication authentication) {
LinkedHashMap<String, Object> properties = (LinkedHashMap<String, Object>) authentication.getDetails();
String loginProperty = properties.get("login");
//Do what you want to do with your property
}

关于java - 在 Java Spring Boot 中从 Principal 中提取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61757551/

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