SpringMVC获取多选框 

@RequestMapping("rolePower")
    public String rolePower(int roleId,@RequestParam("menuIds") List<Integer> menuIds) {
        System.out.println(roleId);
        for (Integer menuId : menuIds) {
            System.out.println(menuId);
        }
        return "redirect:allRole.action";
    }

@RequestParam("menuIds"):定义获取哪些,放进list

 

<c:forEach items="${roleIdList}" var="roleIds">
                                <label class="">
                                    <input type="checkbox" value="${roleIds.roleId}" name="roleIds" id="user-Character-1-0-4">
                                    ${roleIds.roleName}</label>
                                </c:forEach>

多选框的name统一

 

 多选框选中

$("input:checkbox:checked").each(function () {
                alert($(this).val());
                $(this).parents("tr").remove();
            })

 增强版:

function deleteCheck() {
    if (confirm("是否删除?")) {
        $(function () {
            $("input:checkbox:checked").each(function () {
                if ($(this).val() != "all") {
                    $(this).parents("tr").remove();
                }
            })
        })
    }
}

 

进入加载 

<c:if test="${empty stores}">
    <script type="text/javascript">
        $(function () {
            submitForm();
        })
    </script>
</c:if>


        <button type="submit">保存并提交</button>

提交表单

function submitForm() {
    $(function () {
        $("form").submit();// 提交from
    })
}

SpringMVC页面采用C标签获取传进数据

<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

注意EL表达式的设置

导入C标签