object-comparison

How to compare two object variables in EL expression language?

喜你入骨 提交于 2019-11-26 04:57:05
I am creating a drop down list of all languages. The default language selection for the list will be determined by information added by the user: <select> <c:forEach items="${languages}" var="lang"> <c:choose> <c:when test="${lang}.equals(${pageLang})"> <option value="${lang}" selected>${lang}</option> </c:when> <c:otherwise> <option value="${lang}">${lang}</option> </c:otherwise> </c:choose> </c:forEach> </select> .equals doesn't appear to exist in EL. Having had a look here it's suggested I write my own function and then import and use that. As this is a one off tiny thing just for this page

How to compare two object variables in EL expression language?

流过昼夜 提交于 2019-11-26 01:54:20
问题 I am creating a drop down list of all languages. The default language selection for the list will be determined by information added by the user: <select> <c:forEach items=\"${languages}\" var=\"lang\"> <c:choose> <c:when test=\"${lang}.equals(${pageLang})\"> <option value=\"${lang}\" selected>${lang}</option> </c:when> <c:otherwise> <option value=\"${lang}\">${lang}</option> </c:otherwise> </c:choose> </c:forEach> </select> .equals doesn\'t appear to exist in EL. Having had a look here it\'s

What is the difference between == and equals() in Java?

江枫思渺然 提交于 2019-11-25 22:12:01
问题 I wanted to clarify if I understand this correctly: == is a reference comparison, i.e. both objects point to the same memory location .equals() evaluates to the comparison of values in the objects 回答1: In general, the answer to your question is "yes", but... .equals(...) will only compare what it is written to compare, no more, no less. If a class does not override the equals method, then it defaults to the equals(Object o) method of the closest parent class that has overridden this method.