search

Home  >  Q&A  >  body text

java - spring security 无法获取已经登陆的用户ID?

    Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();

直接抛异常 显示为null;

PHP中文网PHP中文网2889 days ago615

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:07:25

    Thanks for the invitation! It must be intercept-url. This URL can obtain the logged-in user.

    <intercept-url pattern="/你的URL或者包含你的URL的配置" access="..." />

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 09:07:25

    If you put this together, who can tell which method returned null?

    reply
    0
  • Cancelreply