Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/365.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Spring中从UI获取对象列表。。?_Java_Spring Mvc - Fatal编程技术网

Java 如何在Spring中从UI获取对象列表。。?

Java 如何在Spring中从UI获取对象列表。。?,java,spring-mvc,Java,Spring Mvc,我已经在UI上显示了arraylist值。Arraylist包含pojo类“Preference”。Preference类有3个字符串成员PreferenceName、PreferenceType和PreferenceValue。 在jsp中,我迭代了arraylist并显示了PreferenceName,以及它的值(使用radiobutton显示),无论它是真是假。 现在当用户提交表单时。我希望arraylist包含这些值。我正在使用Spring。我正在获取其他值,但是否有任何方法获取arra

我已经在UI上显示了arraylist值。Arraylist包含pojo类“Preference”。Preference类有3个字符串成员PreferenceName、PreferenceType和PreferenceValue。
在jsp中,我迭代了arraylist并显示了PreferenceName,以及它的值(使用radiobutton显示),无论它是真是假。
现在当用户提交表单时。我希望arraylist包含这些值。我正在使用Spring。我正在获取其他值,但是否有任何方法获取arraylist值。那么我需要做什么

                        <c:forEach items="${preferences.preferenceList}" var="preference">
                             <tr height="35px" bgcolor="#fafafa" bordercolor="#FFF">
                                <td width="50%"><c:out value="${preference.preferenceName}"/></td>
                                <td width="20%">
                                    <c:if test="${preference.preferenceType=='boolean'}">
                                     <c:if test="${preference.preferenceValue=='true'}">
                                        <input type="radio" name="${preference.preferenceName}" value="true" checked="true">Yes &nbsp;
                                        <input type="radio" name="${preference.preferenceName}" value="false" >No &nbsp;
                                     </c:if>
                                      <c:if test="${preference.preferenceValue=='false'}">
                                        <input type="radio" name="${preference.preferenceName}" value="true" > Yes &nbsp;
                                        <input type="radio" name="${preference.preferenceName}" value="false" checked="true" >No 
                                       </c:if>
                                    </c:if>
                                </td>
                             </tr>
                         </c:forEach>                                                                                                 

对
不
对
不
试试这个:

<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<c:forEach items="${preferences.preferenceList}" var="preference" varStatus="itemRow">
    <c:set var="varPath" value="preferenceList[${itemRow.index}]"/>
    <tr height="35px" bgcolor="#fafafa" bordercolor="#FFF">
        <td width="50%">
            <form:label path="${varPath}.preferenceName">${preference.preferenceName}</form:label>
        </td>
        <td width="20%">
            <c:if test="${preference.preferenceType=='boolean'}">
                <form:radiobutton path="${varPath}.preferenceValue" value="true">Yes</form:radiobutton>
                <form:radiobutton path="${varPath}.preferenceValue" value="false">No</form:radiobutton>
            </c:if>
        </td>
    </tr>
</c:forEach>

${preference.preferenceName}
对
不