@GetMapping("outLogin")
public String outLogin(){
ServletRequestAttributes attributes=(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest();
HttpServletResponse response = attributes.getResponse();
CookieUtils.deleteCookie(request , response ,"token");
return "已退出系统";
}
@GetMapping("/login")
public String LoginUser(User user, HttpServletRequest request , HttpServletResponse response){
if(user.getUsername().equals("admin") && user.getPassword().equals("123")){
CookieUtils.setCookie(request , response , "token" ,"456456456",60*60,"utf-8");
return "登录成功";
}
return "登录失败";
}
标签:return,springMVC,request,HttpServletResponse,controller,user,attributes,response From: https://blog.51cto.com/u_14671216/6398489