JSTL用法,这里不细讲了,主要是if-else的写法:
代码片段:
<c:choose> <c:when test="${user.role eq 1 }"> <a href=‘<%=request.getContextPath() %>/servlet/setAdminServlet?id=${user.id }‘>设为管理员</a> </c:when> <c:otherwise> <a href=‘<%=request.getContextPath() %>/servlet/setGeneralServlet?id=${user.id }‘>取消管理员</a> </c:otherwise> </c:choose> <c:choose> <c:when test="${user.status eq 1 }"> <a href=‘<%=request.getContextPath() %>/servlet/setUserOffServlet?id=${user.id }‘>禁用</a> </c:when> <c:otherwise> <a href=‘<%=request.getContextPath() %>/servlet/setUserOnServlet?id=${user.id }‘>解锁</a> </c:otherwise> </c:choose>
时间: 2024-11-05 01:31:42