如何在 JSTL EL 测试中测试枚举值?
我的 JSP 中有以下块,它将 ENUM 值 {CREATE, CREATE_FROM_CAMPAIGN, OPEN}
转换为漂亮、可读的状态文本。
由于某种原因,针对 'CREATE'
的第一个测试有效,但针对 'CREATE_FROM_CAMPAIGN'
的测试却不起作用。
<c:choose>
<c:when test="${entry.activity eq 'CREATE'}">
<td>was created</td>
</c:when>
<c:when test="$(entry.activity eq 'CREATE_FROM_CAMPAIGN'}">
<td>was created from campaign</td>
</c:when>
<c:otherwise>
<td>was opened (${entry.activity}) </td>
</c:otherwise>
</c:choose>
该输出的一项输出如下:
已打开 (CREATE_FROM_CAMPAIGN)
已打开(OPEN)
为什么第二个测试不起作用?
I have the following block in my JSP, which converts from ENUM values {CREATE, CREATE_FROM_CAMPAIGN, OPEN}
into nice, readable status texts.
For some reason the first test against 'CREATE'
works, but the test against the 'CREATE_FROM_CAMPAIGN'
does not.
<c:choose>
<c:when test="${entry.activity eq 'CREATE'}">
<td>was created</td>
</c:when>
<c:when test="$(entry.activity eq 'CREATE_FROM_CAMPAIGN'}">
<td>was created from campaign</td>
</c:when>
<c:otherwise>
<td>was opened (${entry.activity}) </td>
</c:otherwise>
</c:choose>
One output from this one is as follows:
was opened (CREATE_FROM_CAMPAIGN)
was opened (OPEN)
Why does the second test not work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它不起作用,因为您使用
$(
而不是${
来启动表达式。相应地修复它:
It does not work because you used
$(
instead of${
to start the expression.Fix it accordingly: