Java 在Spring中创建表单并选择不带路径属性
我有以下的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="
<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?