Struts2上Session的使用用法
Struts 2 中Session的用法
在ActionSupport子类的execute方法中存储session
Map session = ActionContext.getContext().getSession();
session.put("logged-in","true");
同样在execute方法中,可以清除session变量
Map session = ActionContext.getContext().getSession();
session.remove("logged-in");
在jsp的head部分引入css文件
<head>
<link href="<s:url value="/css/main.css"/>" rel="stylesheet" type="text/css"/>
</head>[www.iocblog.net 来源]
在jsp访问session
session Time: </b><%=new Date(session.getLastAccessedTime())%>
<a href="<%= request.getContextPath() %>/roseindia/logout.action">Logout</a>
jsp中使用struts-tag访问session变量
<s:if test="#session.login != 'admin'">
<jsp:forward page="/pages/uiTags/Login.jsp" />
</s:if>
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。