登录时使用Shiro
@RequestMapping(value = "/login", method = RequestMethod.POST)
@ResponseBody
public ResponseEntity<RestResult> login(@Valid @RequestBody User user, BindingResult result,
HttpSession session, HttpServletRequest request) {
Subject subject = SecurityUtils.getSubject();
Result result = userService.login(user.getName(), user.getPassword());
if (result.isSuccess()) {
UsernamePasswordToken token = new UsernamePasswordToken(user.getName(), user.getPassword(), false,
request.getRemoteHost());
subject.login(token);
}
return result.toResponseEntity();
}
并以注销方式:
@RequestMapping("/logout")
@ResponseBody
public ResponseEntity<RestResult> logout(HttpSession session) {
Subject subject = SecurityUtils.getSubject();
subject.logout();
return Result.success().build();
}
因为图片显示校长是空的,所以,问题是什么?