I made a login today and saved it with session in the background. I don’t know why I can’t get it and it’s still null.
@ResponseBody @RequestMapping("/ueserLogin") public Object ueserLogin(Model model){ Users userss; System.out.println(request.getParameter("user_number")); if(request.getParameter("user_number")!=null && request.getParameter("user_number")!=""){ userss=userbiz.findUserByNume(request.getParameter("user_number")); if(userss!=null){ //这里我用session保存 request.getSession().setAttribute("users", userss); //输出是null ![图片描述][1] System.out.println(request.getParameter("users")); //还强转不了为对象 //(Users)request.getParameter("users"); return JSON.toJSONString(userss); }else{ return "no"; } }else{ System.out.println("账号不能为空!"); return "no"; } }
Of course the objects you store in
session
cannot be retrieved usingrequest
.