java - I encountered a problem while writing code today, that is, an object that was just saved into the session cannot be read out. I would like to ask what the problem is.
大家讲道理
大家讲道理 2017-06-10 09:48:02
0
1
758

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";
    }
}
大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(1)
typecho

Of course the objects you store in session cannot be retrieved using request.

request.getSession().getAttribute("users"); // 试试
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template