[英]How to Pass <Select> and <input> data from View to a Controller (Spring MVC)
[英]How to get all the item of a jstl select in MVC Spring controller from view
我正在將Spring MVC和JSTL標記用於jsp頁面作為前端...我在視圖中有一個jstl select選項...該選擇是從db中填充的..現在我希望我按一下提交按鈕...我可以將列表框中的所有項目返回到Spring MVC控制器。如何執行此操作?
這是我的JSTL選擇框:-
<form:select id="upperTier" path="propertyCode" cssClass="textfield">
<c:if test="${upperTyrePropertyCodeList!=null}">
<form:options items="${upperTyrePropertyCodeList}" itemValue="propertyCode" itemLabel="propertyCode" />
</c:if>
</form:select>
現在我希望將選擇框的所有項目(upperTyrePropertyCodeList)都返回到控制器...而不是任何選擇索引...。
如果您想將所有upperTyrePropertyCodeList都返回給您提交操作,則可以這樣:
<c:forEach var="index" items="${upperTyrePropertyCodeList}">
<form:hidden name="propertyCode" value="${index.propertyCode}"/>
</c:forEach>
選擇框僅將所選值保存到控制器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.