大家好,又见面了,我是你们的朋友全栈君。
1、创建session:
ActionContext actionContext = ActionContext.getContext(); Map<String, Object> mapSession = actionContext.getSession(); mapSession.put("branch", branch); mapSession.put("permission", per);
2、jsp读取session
if(session.getAttribute("branch") == null||session.getAttribute("permission") == null) { response.setCharacterEncoding("utf-8"); out.print("<script>alert('您还没有登录,请登录') </script>"); out.flush(); out.close(); }
3、java后台读取session的值
ActionContext actionContext = ActionContext.getContext(); Map session = actionContext.getSession(); String inputUserid =(String)session.get("username"); String proving =(String)session.get("proving");
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/154305.html原文链接:https://javaforall.net