开发者

How to populate struts2 combo with string array

开发者 https://www.devze.com 2023-01-11 02:44 出处:网络
statesList is ArrayList that contains String object. String[] states = new String[2]; states[0] = \"CA\";

statesList is ArrayList that contains String object.

String[] states = new String[2];
states[0] = "CA";
states[1] = "California";
statesList.add(states);

//---

<s:select list="statesList"  headerKey="" headerValue="Select State"  name="state"开发者_C百科 listKey="?" listValue="?" />

What to mention in listKey and listValue??


Your statesList is ArrayList that contains String[] object, instead of String.

With this said you can change your code to:

Map<String,String> statesList= new HashMap()<String,String>;
statesList.put("CA","California");

<s:select list="statesList" headerKey="" headerValue="Select State"  name="state" listKey="key" listValue="value" />
0

精彩评论

暂无评论...
验证码 换一张
取 消