java - If Condition is Not Working in JSTL -


i trying set 2 variable using 2 if condition not working. code snippet given below:

<c:foreach items="${user.roles}" var="role">              <span>value : ${role.id }</span> **<!-- print value perfectly-->**          <c:if test="${role.id  == 3}">              <c:set var="admin" value="${role.id}"></c:set>               <span>value : ${val }</span>         </c:if>                       <c:if test="${role.id  == 2}">   **<!-- not work condition here -->**             <c:set var="supporter" value="${role.id}"></c:set>                   <span>value : ${val }</span>                                 </c:if> </c:foreach>  <input type="checkbox" name="roles" value="3" ${admin ==3 ? 'checked' : ''}> supporter <input type="checkbox" name="roles" value="2" ${supporter ==2 ? 'checked' : ''}> admin 

added tag lib:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> 

you use wrong syntax if condition change line

<c:if test="${$rold.id == 3}"> <c:if test="${role.id == 3}">

i think work


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -