我有一个 Spring MVC form:select
,它form:options
与List<Custom_Object>
. 在下面的代码中List<Custom_Object>
命名LOCALIZATION_LIST
。
的path
属性form:select
用于设置选择的选项。
<form:form action="editNode.do" method="post" name="editNodeForm" commandName="editElementDetails">
<table>
<tr>
<td>Data Type</td>
<td>
<form:select path="datatype" onchange="" cssClass="large" id="datatypes">
<c:if test="${! empty LOCALIZATION_LIST}">
<form:options items="${LOCALIZATION_LIST}" itemLabel="local_Name" itemValue="local_Name"/>
</c:if>
</form:select>
</td>
</tr>
</table>
</form:form>
现在我的问题是,可能存在一个场景,editElementDetails.datatype
其中可能包含一个根本不存在的值LOCALIZATION_LIST
。所以目前 Spring MVC 显示LOCALIZATION_LIST
为选中的第一个元素。
有没有办法可以确定用于设置所选对象的绑定操作是否form:options
成功form:select
?
因此,当绑定不成功时,我可以添加一个额外的表单:表单中带有新值的选项。