SpringSecurity全局上下文中获取token,而不是请求中获取的方式
// 获取全局Authentication接口里面的token值
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String token = ((Jwt)principal).getTokenValue();
// 获取全局Authentication接口里面的token值
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
String token = ((Jwt)principal).getTokenValue();
相关推荐