我有scriplet和jstl代码,它们检查用户的电子邮件是否为root
,如果是,请将div添加到标题中。脚本代码有效,而jstl代码无效。
代码代码:
<%
if (user.getEmail().equals("root")) {
%>
<div class="button logout-button"
onclick="location.href =
'${pageContext.request.contextPath}/initializedatabase'">
Initialize the database
</div>
<%
}
%>
jstl代码:
<c:if test =
"${sessionScope.user != null} &&
${sessionScope.user.getEmail() == 'root'}">
<div class="button initialize-button"
onclick="location.href='${pageContext.request.contextPath}/initializeddatabase'">
Initialize Database
</div>
</c:if>
尝试
<c:if test =
"${sessionScope.user != null} &&
${sessionScope.user.getEmail() == 'root'}">
to
<c:if test =
"${sessionScope.user != null && sessionScope.user.getEmail() eq 'root'}">