我在我的单页中设置了许多 c:set 声明。我还将我的 roleId 设置为我的会话。现在,当我制作其他 c:set 时,我的会话角色 ID 受到了影响。我确认了这一点,因为我在我的页面中显示了我的会话 ID。登录后我的会话 ID 是正确的,但是当我刷新页面时,我的会话 ID 发生了变化。为什么?这是我的代码
<%@page import="request.RequestDAO"%>
<%@page import="request.RequestItems"%>
<%@include file="/WEB-INF/common/taglibs.jsp"%>
<%@ page import="message.MessageItems"%>
<%@ page import="message.NewMessageDAO"%>
<div id="menu-wrapper">
<div id="menu">
<span class="menu-header">Calendar</span>
<div id="adminCalendar"></div>
</div>
<div id="menu">
<span class="menu-header">Directories <%=((Long) session.getAttribute("role")).longValue()%> </span>
<ul>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-organizations">Organization </a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-medical-service">Medical Service</a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-evacuation-center">Evacuation Centers</a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-fire-suppression-group">Fire Suppression Groups</a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-medical-facilities">Medical Facilities</a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-rescue-organization">Rescue Organizations</a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-agency">Agency</a></li>
<li><a href="${pageContext.request.contextPath}/directory/list-of-registered-schools">Schools</a></li>
</ul>
</div>
<c:set var="admin" scope="session" value='<%=((Long) session.getAttribute("role")).longValue()%>' />
<c:if test="${admin == 121}">
<div id="menu">
<span class="menu-header">Registration</span>
<ul>
<li><a href="${pageContext.request.contextPath}/registration/organization-registry">Organization Registry </a></li>
<li><a href="${pageContext.request.contextPath}/registration/emergency-medical-service">Emergency Medical Service Registry</a></li>
<li><a href="${pageContext.request.contextPath}/registration/register-evacuation-center">Evacuation Centers Registry</a></li>
<li><a href="${pageContext.request.contextPath}/registration/register-fire-suppression-group">Fire Suppression Group Registry</a></li>
<li><a href="${pageContext.request.contextPath}/registration/register-medical-facilities">Medical Facilities Registry</a></li>
<li><a href="${pageContext.request.contextPath}/registration/register-rescue-organizations">Rescue Organizations Registry</a></li>
<li><a href="${pageContext.request.contextPath}/registration/agency-registration">Agency Registry</a></li>
<li><a href="${pageContext.request.contextPath}/registration/school-registration">School Registry</a></li>
</ul>
</div>
</c:if>
<%
long id = ((Long) session.getAttribute("userId")).longValue();
MessageItems message = new NewMessageDAO().NewMessages(id);
RequestItems NewRequest = new RequestDAO().NewRequests(id);
%>
<div id="menu">
<span class="menu-header">User Option</span>
<ul>
<li><a href="${pageContext.request.contextPath}/registration/organization-registry">My Account</a></li>
<li><a href="${pageContext.request.contextPath}/registration/emergency-medical-service">Change Password</a></li>
<li><a href="${pageContext.request.contextPath}/message/inbox">My Messages
<c:set var="role" scope="session" value='<%=message.getNewMessages()%>' />
<c:if test="${role == 0}">
<li><a href="${pageContext.request.contextPath}/message/inbox">My Messages<label></label></a></li>
</c:if>
<c:if test="${role != 0}">
<li style="font-weight: bold"><a href="${pageContext.request.contextPath}/message/inbox">My Messages <label>(<%=message.getNewMessages()%>)
</label></a></li>
</c:if>
<li><a href="${pageContext.request.contextPath}/message/new-message">Send Message</a></li>
<c:set var="role1" scope="session" value='<%=NewRequest.getNewRequest()%>' />
<c:if test="${role1 == 0}">
<li><a href="${pageContext.request.contextPath}/request/request-inbox">My Requests<label></label></a></li>
</c:if>
<c:if test="${role1 != 0}">
<li style="font-weight: bold"><a href="${pageContext.request.contextPath}/request/request-inbox">My Requests <label>(<%=NewRequest.getNewRequest()%>)
</label></a></li>
</c:if>
<li><a href="${pageContext.request.contextPath}/request/new-request">Make Request</a></li>
<li><a href="${pageContext.request.contextPath}/request/request-inbox">My Requests</a></li>
<li><a href="${pageContext.request.contextPath}/action/add-user">Add user</a></li>
<li><a href="${pageContext.request.contextPath}/action/view-all-user">View user</a></li>
</ul>
</div>
</div>