get current user
02 - 从SpringSecurity中获取当前用户
一行搞定
SecurityContextHolder.getContext().getAuthentication().getPrincipal();

这里自定义了一个UserDetailsImpl类实现UserDetails接口, 此时loadUserByUsername方法的返回对象的类型也要改成自定义类型(01篇最后那样), 不然报错。
测试一下: 登陆后跳转到/user, 返回当前用户信息

一行搞定
SecurityContextHolder.getContext().getAuthentication().getPrincipal();

这里自定义了一个UserDetailsImpl类实现UserDetails接口, 此时loadUserByUsername方法的返回对象的类型也要改成自定义类型(01篇最后那样), 不然报错。
测试一下: 登陆后跳转到/user, 返回当前用户信息

