在JSP页面上填充一组域对象

时间:2014-02-26 15:00:19

标签: java spring-mvc navigation

我有一组权限和控制器,它们添加到设置的模型中。我需要用用户选择的参数填充一组。

<form:form id="intUserPermissions" method="post" action="/user/new/2" 
    modelAttribute="permissions">
    <c:forEach items="${permissions}" var="permission">
        <p><label for="${permission.name}"></label>
            <b>${permission.name}</b>
            <form:checkbox path="permission.name" id="${permission.name}"/>
        </p>
    </c:forEach>
    <div class="content"><input class="submit" type="submit" value="Set"></div>
</form:form>


public String createForm(@ModelAttribute User user,
                             @ModelAttribute HashSet<Permission> permissions,
                             @PathVariable("pageId") Integer pageId,
                             ModelMap model) {

    <...>

    model.addAttribute("permissions", service.getPermissions());

    <...>
}

如何使用modelAttribute的权限填充集合?

0 个答案:

没有答案