Search code examples
jspjstl

How to check content of field in JSP


I have table:

<c:forEach var="employee" items="${employees}">
    <tr>
        <td>${employee.id}</td>
        <td>${employee.gender.gender}</td>
        <td>${employee.name}</td>
        <td>${employee.surname}</td>
        <c:if test="${employee.appointment.appointment eq NAVIGATOR}">//Checking value of field
            <td>${employee.appointment.appointment}</td>
        </c:if>
    </tr>
</c:forEach>

I want to check value of field:

${employee.appointment.appointment}

How to do it?


Solution

  • You would need to put the NAVIGATOR in quotes like 'NAVIGATOR', if you are checking for the value of the employee.appointment.appointment is actually NAVIGATOR.

    <c:if test="${employee.appointment.appointment eq 'NAVIGATOR'}">
          <td>${employee.appointment.appointment}</td>
    </c:if>