如何在JSP中将“模型对象属性ArrayList <string>”值显示为DROP DOWN值

时间:2015-09-03 11:26:05

标签: java jsp spring-mvc arraylist

<form:form action="saveNewUsers" method="post" modelAttribute="users">
        <table>
        <tr><td>Id</td>
                <td><form:input path="id"/></td>
            </tr>
            <tr>
                <td>User</td>
                <td><form:input path="user" /></td>
            </tr>
            <tr>
                <td>Password</td>
                <td><form:input path="password" /></td>
            </tr>
            <tr>
                <td>FirstName</td>
                <td><form:input path="first_name" /></td>
            </tr>

            <tr>
                <td>LastName</td>
                <td><form:input path="last_name" /></td>
            </tr>

            <tr>
                <td>Group Id</td>
            <td>
               <select name="GroupId">
                 <c:forEach items="${users.al}" var="item">
                   <option value="${item.value}">${item.value}</option>
                 </c:forEach>
                </select>
             </td>

             <tr>
            <td colspan="2" align="center"><input type="submit" value="Save"></td>
            </tr>

     </table> 

请让我知道如何从'users'的ModelObject获取ArrayList属性,并在JSP中将ArrayList的值打印为DROPDOWN Menu。
实际上我从Spring MVC的Controller发送'用户'模型对象

0 个答案:

没有答案