JSP 页面 checkbox 实现单选、多选效果

核心代码:

roleList:request.setAttribute("roleList", roleList);(java代码)

主要是修改 type 类型:

    单选:type="radio"

    多选:type="checkbox"

-----------------------------------------------------------------------------------------------------------

<c:forEach var="role" items="${roleList}" varStatus="status">

             <c:if test="${userRole.roleId eq  role.roleId}">
                            <input type="radio" name="roleId" value='${role.roleId}' checked="checked"/>

                            ${role.roleName}
              </c:if>
              <c:if test="${userRole.roleId != role.roleId}">
                            <input type='radio' name="roleId" value='${role.roleId}'/>${role.roleName}
              </c:if>                   

</c:forEach>

你可能感兴趣的:(JSP 页面 checkbox 实现单选、多选效果)