token通过redis缓存传递过程

登录:loginController
String token=JwtUtil.sign(user.getName(), user.getPwd());
redisTemplateService.set(token, user);
return ResponseDataUtil.success(token,user);
登录返回:login.js
localStorage.setItem(“token”,data.msg);

ajax使用token
url: “DoExercise/judge”,
headers: {“TOKEN”:localStorage.getItem(“token”)},

Controller接受token
User loginUser= redisTemplateService.get(request.getHeader(“TOKEN”),User.class);
answerFrom.setUid(loginUser.getId());

你可能感兴趣的:(SpringBoot2)