How do I get a list of Strings in a select from Struts2?

Posted on

Question :

I have a select on my page that should have its value and its legend populated through a list of Strings that come from my Action.

I’m sending the list correctly because I see the combo have the number of elements of the same size as the list, but I do not know how to identify the value and description in TagLib.

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

What should I use in listKey and listValue to populate the options?

The method in action:

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

    

Answer :

The answer to this question is to get the attributes listKey and listValue .

Source: link

    

Leave a Reply

Your email address will not be published. Required fields are marked *