醋椒豆腐 2021-05-19 22:28 采纳率: 0%
浏览 753

shiro 框架中SecurityUtils.getSubject().getPrincipal()

SecurityUtils.getSubject().getPrincipal(); shiro 框架中这个在首次登陆为null,不知道从呢里去排除代码
 protected XtyhxxbEntity getUser() {
        XtyhxxbEntity entity = (XtyhxxbEntity) SecurityUtils.getSubject().getPrincipal();
        if (entity != null && StringUtils.isEmpty(entity.getJsmc())) {
            try {
                entity.setJsmc(sysDepartmentService.getDepartment(entity.getJsbh()));
            } catch (Exception e) {
                entity.setJsmc(" ");
            }
        }
        // 登陆人不是系统管理员并且民警编号不为空的情况下查询数据
        if (!Constant.SUPER_ADMIN.equals(entity.getYhbh()) && StrUtil.isNotBlank(entity.getMjbh())) {
            MjMjxxbEntity mjInfo = mjMjxxbService.getById(entity.getMjbh());
            entity.setMjgwid(mjInfo.getMjgwdm());
            entity.setMjgwmc(mjInfo.getMjgwmc());
        }
        return entity;
    }
  • 写回答

3条回答 默认 最新

  • CSDN专家-sinJack 2021-05-20 08:18
    关注

    realm认证写的有问题。可参考 https://blog.csdn.net/weixin_42672204/article/details/104182859?utm_source=app&app_version=4.7.1

    评论

报告相同问题?