how to loop checkboxes using for loop in jsp?

vidy :

I am trying to loop checkboxes using for loop. I write c:forEach to loop through checkboxes. Checkboxes are appear as per the data fields in the database. But when i try to check any of these checkboxes, only one checkbox get checked. What am i doing wrong here?

Checkbox

<c:forEach items="${brandlist}" var="brand" begin="0" end="5"
    varStatus="loop">
    <div class="custom-control custom-checkbox">
        <input type="checkbox" class="custom-control-input" id="customCheck1"
            name="brand"> <label class="custom-control-label" for="customCheck1">${brand.brand}</label>
    </div>
</c:forEach>

Why only one checkbox is checked?

vidy :

My problem solved after adding

<c:forEach items="${brandlist}" var="brand" begin="0" end="5"
varStatus="loop">
<div class="custom-control custom-checkbox">
    <input type="checkbox" class="custom-control-input"
        id="${brand.brand}" name="${brand.brand}"> <label
        class="custom-control-label" for="${brand.brand}">${brand.brand}</label>
</div>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=107086&siteId=1