SpringMvc 中綁定 checkbox 標簽到form 中的List


<table align="center">
        <tr>
            <td>ID</td>
            <td>Role Name</td>
        </tr>
        <c:forEach items="${roleList}" var="role">
            <tr>
                <td><form:checkbox path="roles" value="${role}" label="${role.id}" /></td>
                <td><c:out value="${role.name}" /></td>
            </tr>
        </c:forEach>
</table>

<from:checkboxes> 標簽中的items 只能是數組、list<String>  、map

<div class="controls">
     <c:forEach items="${smsGroups}" var="smsGroup" varStatus="status">
           <tr>
               <form:checkbox path="smsGroups[${status.index}].groupid" 
                            value="${smsGroup.groupid}" label="${smsGroup.groupname}" />
           </tr>
     </c:forEach>
 </div>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM