【#文档大全网# 导语】以下是®文档大全网的小编为您整理的《session存取》,欢迎阅读!
-----存入session
HttpSession session = request.getSession(true); ||
HttpSession session = ServletActionContext.getRequest().getSession(true);
session.setAttribute("authCode", authCode);
session.setAttribute("username", username);
session.setAttribute("user", user);
------从session中取出
HttpSession session = ServletActionContext.getRequest().getSession(true); ||
String authCode = (String) session.getAttribute("authCode");
HttpSession session = ServletActionContext.getRequest().getSession(true);
userName=(String) session.getAttribute("username");
-------------------------------------------------------------------------------
-----存入session
HttpServletRequest request = ServletActionContext.getRequest();
request.getSession().setAttribute("username", username);
------------------------------------------------------------------------------
userName=(String) session.getAttribute("username");
semtask = this.semtaskService.getTaskNoUp(pagenow, session.getAttribute("username").toString());
----获取前台传入的用户名和密码
ActionContext ac = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest)ac.get(ServletActionContext.HTTP_REQUEST);
String userName = request.getParameter("username");
String passWord = request.getParameter("password");
---------页面取值
HttpServletRequest Request=ServletActionContext.getRequest();
String userName = Request.getParameter("username");