我在爲我的jsp頁面編寫if-then-else條件時遇到了一些問題。我認爲這個問題與我的報價有關。也有可能在JavaScript中使用JSTL?JSTL if-then-else session屬性
代碼
<c:choose>
<c:when test= "'<%=request.getSession().getAttribute("userName")%>' == Guest">
<button class="btn" id="getCitizens" onclick="DoGuestAccess()" type="button">Guest Access</button>
</c:when>
<c:otherwise>
<button class="btn" id="getCitizens" onclick="DoUsersAccess()" type="button">User Access</button>
</c:otherwise>
</c:choose>
錯誤
org.apache.jasper.JasperException: /WEB-INF/jsp/newpage.jsp (line: 485, column: 71) equal symbol expected
沒有事實並非如此。 JSTL只能在服務器端解釋。 – Farid
所以我應該將JSTL值傳遞給html元素,然後使用javascript從條件元素中獲取值? – devdar
JSTL可以用來渲染JavaScript。 –