赞
踩
Enumeration<String> headerNames = request.getHeaderNames();
while(headerNames.hasMoreElements()) {//判断是否还有下一个元素
String nextElement = headerNames.nextElement();//获取headerNames集合中的请求头
String header2 = request.getHeader(nextElement);//通过请求头得到请求内容
// log.info("请求头=========={}" + nextElement + "VALUE:" + header2);
System.out.println(nextElement+":"+header2);
}
/** 登录 */ @PostMapping("/login") public ResultUtil login(@RequestBody LoginModel model, HttpServletRequest request){ Enumeration<String> headerNames = request.getHeaderNames(); while(headerNames.hasMoreElements()) {//判断是否还有下一个元素 String nextElement = headerNames.nextElement();//获取headerNames集合中的请求头 String header2 = request.getHeader(nextElement);//通过请求头得到请求内容 // log.info("请求头=========={}" + nextElement + "VALUE:" + header2); System.out.println(nextElement+":"+header2); } System.out.println("已打印完"); //保存登录日志 // SysLog sysLog = new SysLog(IpUtil.getIpAddress(request),"用户登录","login"); // sysLog.setId(IdUtil.getSnowflakeNextIdStr()); // sysLog.setCreateBy(model.getUserName()); // sysLog.setState("登录成功"); // try { // /*code = code.toUpperCase(); // Object verCode = redisUtil.get(BaseConstant.verCode+code); // if (Objects.isNull(verCode)) { // return ResultUtil.error("验证码已失效,请重新输入"); // } // redisUtil.del(BaseConstant.verCode+code); // password = RSAUtil.decrypt(password); //密码私钥解密*/ // SysSafe safe = sysSafeService.list().get(0); // SysUser user = passwordErrorNum(model.getUserName(), model.getPassword(), safe); // sysUserService.setDataScope(user); // 设置用户的数据范围查询条件 // String oldToken = StpUtil.getTokenValueByLoginId(user.getId()); // // 先根据登录id获取token // if (StrUtil.isNotBlank(oldToken)){ // StpUtil.logout(user.getId()); // 如果token不为空,先退出登录 // } // StpUtil.login(user.getId()); // String tokenValue = StpUtil.getTokenValue(); // sysLog.setInfo(model.getUserName()+"登录成功"); // StpUtil.getSession().set("user",user); // sysLogService.save(sysLog); // int i = safe.getIdleTimeSetting(); // //如果系统闲置时间为0,设置token和session永不过期 // if (i==0){ // SaTokenDao saTokenDao = SaManager.getSaTokenDao(); // SaTokenConfig config = SaManager.getConfig(); // saTokenDao.updateSessionTimeout(StpUtil.getSession().getId(),-1); // saTokenDao.updateTimeout(BaseConstant.tokenCachePrefix+tokenValue,-1); // saTokenDao.updateTimeout(BaseConstant.cachePrefix+"last-activity:"+tokenValue,-1); // config.setActivityTimeout(-1); // } // return ResultUtil.success(tokenValue); // } catch (ExceptionVo e) { // sysLog.setInfo(e.getMessage()); // sysLog.setState("登录失败"); // sysLogService.save(sysLog); // return ResultUtil.error(e.getCode(),e.getMessage()); // }catch (Exception e) { // sysLog.setInfo(BaseConstant.UNKNOWN_EXCEPTION); // sysLog.setState("登录失败"); // sysLogService.save(sysLog); // e.printStackTrace(); // return ResultUtil.error(BaseConstant.UNKNOWN_EXCEPTION); // } return ResultUtil.success() }
打印结果
host:192.168.0.180:8004
connection:keep-alive
content-length:43
accept:application/json, text/plain, */*
user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0
content-type:application/json
origin:http://localhost
referer:http://localhost/
accept-encoding:gzip, deflate
accept-language:zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6
已打印完
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。