如果字符串不相等,我如何比较?

时间:2012-08-27 14:55:23

标签: java jsp jstl

我试图只根据字符串是否不等于显示某些内容:

<c:if test="${content.getContentType().getName() != "MCE"}">
<li><a href="#publish-history" id="publishHistoryTab">Publish History</a></li>
</c:if>

不断抛出错误org.apache.jasper.JasperException: /WEB-INF/jsp/content/manage.jsp(14,60) PWC6212: equal symbol expected

我也尝试过not eq而不是!=

not equal to的有效语法是什么?

1 个答案:

答案 0 :(得分:123)

Either != or ne will work,但您需要排除accessor syntax and nested quotes

<c:if test="${content.contentType.name ne 'MCE'}">
    <%-- snip --%>
</c:if>