我有以下查詢參數:如何使用boostrap select在每個彈簧mvc3的選擇列表中設置選定的項目?
http://localhost:8085/myPage?selectListId=2
我在GET方法去皮,切開的「selectListId」參數從查詢字符串,我想設置我的下拉列表中該指標值的選擇項。
我使用引導程序,所以不知道是否重要。該列表從我從spring mvc3控制器傳入的viewModel中填充。
<form class="form-horizontal" action="myController/indexSubmit" method="post">
<select name="selectList" class="form-control" placeholder=".input-medium" height>
<c:forEach items="${viewModel.getlistitems()}" var="item" varStatus="count">
<option value="${count.index}">${item }</option>
</c:forEach>
</select>
<button type="submit" class="btn btn-primary btn-medium">Submit</button>
</form>
我該如何設置此值(最好不要使用javascript)?謝謝!
你問如何控制器方法循環遍歷你添加到控制器中'Model'列表的列表元素? –
嗨...不,我有這個部分...這個清單填充得很好。但是,在回發中,我將選定的項目存儲在查詢參數中...重定向回主頁面,列表下拉列表...但想要設置具有所選項目索引的下拉列表。 – JaJ