Struts2 - 如何使用字符串列表填充选择标签



我有一个选择,必须用字符串列表填充其选项。选项值和文本应相等。

我知道我正在正确发送列表,因为选择呈现的元素数量等于列表的大小。

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

发生的情况是,这些选项在没有值和文本的情况下呈现,因为我不知道我应该在 Struts2 taglib 的选择标签的listKeylistValue属性中引用什么。

操作中的方法:

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

如果省略lisKeylistValue属性,则 Struts2 将使用字符串文本作为键和值。

尝试:

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

最新更新