获取sessionID的步骤

String str = String.valueOf(value);
                    支付串判断为null的方法,要加双引号 "  "
                 String str = String.valueOf(value);
  `在这里插入代码片`  if (StringUtils.isNotBlank(str) && str != "null")

StringUtils.isNotBlank(str)是判断为空和为NULL的方法



在这里插入代码片
@PostMapping(value = "login.do")
    @ResponseBody
    public ResponseBean login(HttpSession session, @RequestParam("username") String username, @RequestParam("password") String password) {
        ResponseBean response = new ResponseBean();
        if (StringUtil.isEmpty(username)) throw new ParamException("账号不能为空");
        if (StringUtil.isEmpty(password)) throw new ParamException("密码不能为空");
        AdminToken token = new AdminToken(username, password);
        Subject currentUser = SecurityUtils.getSubject();
        AdminUser adminUser = adminUserService.selectByAdminUserName(username);
        if (ObjectUtils.isEmpty(adminUser)) {
            response.setState(501);
            throw new ParamException("请输入正确的账号");
        }
        //查询一级菜单栏
        List<ClubAdminModule> clubAdminModules = adminUserService.selectFirstModule(adminUser.getRoleId());
        for(ClubAdminModule cdm:clubAdminModules){
            //根据父id查询子菜单
            List<ClubAdminModule> childsource=adminUserService.selectModuleItems(cdm.getId());
            cdm.setChildren(childsource);
        }
        Map<String, Object> map=new HashMap<>();
        map.put("permisition",clubAdminModules);
        session.setAttribute("permisition",clubAdminModules);
        session.setAttribute("name","1233646464645415");
        try {
            currentUser.login(token);
            response.setState(200);
        } catch (IncorrectCredentialsException e) {
            response.setStatus(false);
            response.setMsg("请输入正确的密码");
            response.setState(502);
        }
        //id是cookie里的session ID
        String id = (String) currentUser.getSession().getId();
        System.out.println("111111111111111111111"+id);
        //获取session	id
        token.setSessionId(currentUser.getSession().getId());
        response.setObj(token);
        return response;
    }

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值