我有以下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.
事实是,我只想将数据存储在其他文本框中,而不是上面选择(下拉列表)中的数据。所以,我试图删除属性路径,但编译器抱怨说:
Missing required attribute "path"
相反,如果我离开路径,运行时也会抱怨,因为我的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?
如何以与所有其他值不同的方式存储上述下拉列表。这应该只是一个下拉列表来填充其他项目列表,我只需要存储列表而不是下拉列表。我怎么能这样做?