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
?
Note: When comparing two strings in java, we should not use the == or != operators. These operators actually test references, and since multiple String objects can represent the same String, this is liable to give the wrong answer.
The not-equal-to operator ( != ) returns true if the operands don't have the same value; otherwise, it returns false .
You can use "!= " and "is not" for not equal operation in Python. The python != ( not equal operator ) return True, if the values of the two Python operands given on each side of the operator are not equal, otherwise false .
You should not use == (equality operator) to compare these strings because they compare the reference of the string, i.e. whether they are the same object or not. On the other hand, equals() method compares whether the value of the strings is equal, and not the object itself.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With