java中session的使用


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");

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM