public String addFriend(@RequestParam long friendId, Model model) {
User currentUser = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); //1.
在我的spring boot应用程序中,在我的rest控制器中,我成功地注入了一个Authentication实例来获取会话的用户信息。@GetMapping String username = auth.getName().replaceFirst(".*?\\\\", ""); // to remove windows domain name
// the rest