我在會話中存儲了Usertype。這是打印你好,管理員!當我使用<%= session.getAttribute( 「用戶類型」)%>,但並沒有顯示如何在JSTL中使用會話?
<p>hello, <%= session.getAttribute("Usertype") %></p>
<c:set scope="session" var="Usertype" value="${param.Usertype}" />
<c:choose>
<c:when test="${Usertype == 'Employee'}">
<div class="nav">
<ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
<li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
<li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
</ul>
</div>
</c:when>
<c:when test="${Usertype == 'Manager'}">
<div class="nav">
<ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
<li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
<li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
<li><a href="newemployee.jsp">Add New Employeer</a></li>
<li><a href="retrieve.jsp">Retrieve TimeSheet</a></li>
</ul>
</div>
</c:when>
<c:when test="${Usertype == 'Admin'}">
<div class="nav">
<ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
<li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
<li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
<li><a href="newemployee.jsp">Add New Employeer</a></li>
<li><a href="retrieve.jsp">Retrieve TimeSheet</a></li>
</ul>
</div>
</c:when>
您是否有結束標記_ _?並且使用_ _作爲最後一次測試,_ _與_if-else if-else_語句等效。 –
drgPP
@drgPP對不起,我已收到的標籤...它沒有複製! –
dpk
爲了確保您正確存儲了jstl變量中的值,可以在聲明後使用' '將其打印出來。 –
drgPP