Jsp scriplet起作用,而jstl不起作用

问题描述 投票:0回答:1

我有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>
jsp jstl el
1个回答
0
投票

尝试

<c:if test =
      "${sessionScope.user != null} &&
       ${sessionScope.user.getEmail() == 'root'}">

to

<c:if test =
      "${sessionScope.user != null && sessionScope.user.getEmail() eq 'root'}">
© www.soinside.com 2019 - 2024. All rights reserved.