簡體   English   中英

Struts2-如何用字符串列表填充選擇標記?

[英]Struts2 - How to populate a select tag with a list of String?

我有一個選擇,必須用字符串列表填充其選項。 選項值和文本應相等。

我知道我正確地發送了列表,因為select呈現的元素數量等於列表的大小。

<s:select name="status" list="status" headerKey="" headerValue="-- Select --" id="status" listKey="" listValue="" />

發生的情況是,選項呈現時沒有值和文本,因為我不知道應該在Struts2 taglib的select標簽的listKeylistValue屬性中引用什么。

動作中的方法:

public List<String> getStatus() {
    return Arrays.asList("Active", "Inactive");
}

如果省略lisKeylistValue屬性,則Struts2將使用字符串文本作為鍵和值。

嘗試:

<s:select name="status" list="status" headerKey="" headerValue="-- Select --" id="status" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM