- controller中,直接参数注入
@RequestMapping
public void execute(Principal principal){}
- 其他bean中
SecurityContextHolder.getContext().getAuthentication().getPrincipal()
@RequestMapping
public void execute(Principal principal){}
SecurityContextHolder.getContext().getAuthentication().getPrincipal()