ChatGPT解决这个技术问题 Extra ChatGPT

How do I compare if a string is not equal to?

I'm trying to only show something based on if a string is not equal to:

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

It keeps throwing the error org.apache.jasper.JasperException: /WEB-INF/jsp/content/manage.jsp(14,60) PWC6212: equal symbol expected

I've also tried not eq instead of !=

What is the valid syntax for not equal to?

try "${not (content.getContentType().getName() eq 'MCE')}". Also pay attention to the quotation marks you are using, because the above expression is incorrect.

M
Matt Ball

Either != or ne will work, but you need to get the accessor syntax and nested quotes sorted out.

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

Works but Eclipse returns Syntax error on token "ne", invalid AssignmentOperator