[英]Spring form option default selected
我在下拉列表中選擇默認值時遇到問題。 我的jsp中的代碼如下
<form:select path="codes" multiple="false">
<form:option value="NONE" label="--- Select Code ---" />
<form:options items="${statusQueryForm.codes}" />
</form:select>
以下是statusQueryForm中的代碼:
public void setCodes(Collection<String> codes) {
this.codes = codes ;
}
public Collection<String> getCodes() {
return codes;
}
代碼包含數組列表,字符串包含數據,例如{“ 123”,“ 345”}
現在,當頁面被加載時,最后一個選項被選中345。默認情況下,我要選擇的是“選擇代碼”。
請有人可以指導我正確的方向。 我試圖理解文檔,但是在此示例中未能達到某種意義。
好吧,我能夠通過向StatusQueryForm添加更多屬性代碼來解決此問題。 Jsp代碼更改如下:.path從代碼更改為代碼
<form:select path="code" multiple="false">
<form:option value="NONE" label="--- Select Code ---" />
<form:options items="${statusQueryForm.codes}" />
</form:select>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.