user3767879
user3767879

Reputation: 43

the if statement syntax in the jsp

mvc, jsp and bootstrap in which i am passing 2 model attributes

  1. model.addAttribute("map",map)

  2. model.addAttribute("size",SIZE)

now on the jsp i want to iterate over this map and want to check if map value matches the SIZE varibale value for which i tried below syntax

<div id="selector" class="btn-group">

        < c:forEach items="${maps}" var="buttonName"  varStatus="counter"> 

                 <div class="row">
                       <div class="col-sm-8">     


                           <c:if test="${buttonName.key} == ${SIZE}">
                                 <button type="button" id="a" >cat</button>  
                            </c:if>

                < /div>
                < /div>
                < br/>                                      
         < /c:forEach>
         < /div>

but this is not working , please let me know if the if syntax is correct ?

Upvotes: 1

Views: 61

Answers (1)

WilQu
WilQu

Reputation: 7383

${} is not used to enclose a single variable but the whole statement. And you should use eq instead of ==. So the correct syntax is:

${buttonName.key eq SIZE}

Upvotes: 3

Related Questions