SSH框架z中登录功能如何将用户保存在session
主题:SSH框架z中登录功能如何将用户保存在session
办法:
1、Action中:
1 HttpServletRequest request=(HttpServletRequest) ServletActionContext.getRequest(); 2 HttpSession session=request.getSession(); 3 session.setAttribute("Admin", admin);
2、jsp页面获取:
用struts标签: <s:property value="#session.Admin.adminName" />
用EL表达式:${session.Admin.adminName}
用java代码:<%=session.getAttribute("Admin.adminName")%>