简体   繁体   English

JSP。 枚举比较/平等

[英]jsp. enum comparison / equality

I have following jsp fragment: 我有以下jsp片段:

                       <td class="">${campaign.moderated}
                            <c:if test="${campaign.moderated} == TRUE">
                                <a href="#">click me</a>
                            </c:if>
                        </td>

Campaign class: Campaign类:

public class Campaign {
      //...
      private ModerationStatus moderated;
      //get and set
}

ModerationStatus : 审核状态:

public enum ModerationStatus {
    TRUE,
    FALSE,
    IN_PROGRESS
}

I cannot achieve the situation when a tag will render on jsp. 我无法实现的情况时, a标签将呈现的JSP。

what Do I wrong? 我错了什么?

PS PS

This table cell looks like this: 此表格单元格如下所示:

在此输入图像描述

this works: 这工作:

                          <c:if test="${campaign.moderated eq 'TRUE'}">
                                <a href="#">click me</a>
                            </c:if>

Enum is represented in JSP as string. 枚举在JSP中表示为字符串。 Change your code 改变你的代码

<c:if test="${campaign.moderated} == TRUE">

To this 对此

 <c:if test="${campaign.moderated} == 'TRUE'}">

So the full code is 所以完整的代码是

  <td class="">${campaign.moderated}
                        <c:if test="${campaign.moderated} == 'TRUE'}">
                            <a href="#">click me</a>
                        </c:if>
                    </td>

EDIT You did not closed bracket after test in if . 编辑你是否测试后没有关闭括号。 I updated code above 我更新了上面的代码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM