Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.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中创建表单并选择不带路径属性_Java_Spring - Fatal编程技术网

Java 在Spring中创建表单并选择不带路径属性

Java 在Spring中创建表单并选择不带路径属性,java,spring,Java,Spring,我有以下的Spring表单: <form:form method="POST" modelAttribute="students" cssClass="my-css" id="my-form"> <form:select id="carInput" path="cars" class="input-xlarge"> <c:forEach items="

我有以下的Spring表单:

<form:form method="POST" modelAttribute="students"
        cssClass="my-css" id="my-form">

            <form:select id="carInput" path="cars" 
                class="input-xlarge">
                    <c:forEach items="${carsList}" var="car">
                        <form:option value="${car.id}" label="${car.model}"></form:option>
                    </c:forEach>
            </form:select>

etc. etc.
相反,如果我离开路径,运行时也会抱怨,因为我的DTO不包含所需的属性设置器:

11:37:06,902 ERROR [org.springframework.web.servlet.tags.form.SelectTag] (http-localhost-127.0.0.1-8080-2) Invalid property 'cars' of bean class [uk.co.bau.dto.Students]: Bean property 'cars' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?: org.springframework.beans.NotReadablePropertyException: Invalid property 'cars' of bean class [uk.co.bau.dto.Students]: Bean property 'cars' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

如何使上述下拉列表不象所有其他值那样存储。这应该只是一个下拉列表,以填充其他项目列表,我只需要存储列表,而不需要下拉列表。我该怎么做呢?

代替
c:forEach
<代码>在一行中产生相同的结果。
11:37:06,902 ERROR [org.springframework.web.servlet.tags.form.SelectTag] (http-localhost-127.0.0.1-8080-2) Invalid property 'cars' of bean class [uk.co.bau.dto.Students]: Bean property 'cars' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?: org.springframework.beans.NotReadablePropertyException: Invalid property 'cars' of bean class [uk.co.bau.dto.Students]: Bean property 'cars' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?