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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -