Struts2在select标签中使用Map

Cha*_*ana 7 struts2

你可以在struts2 select标签中轻松使用List,但有没有办法在标签中使用Map?如果可能,请提供示例代码......

thanx!

Kar*_*tik 8

在我的动作课上

public class MyAction extends ActionSupport {
   private Map<String, String> map;

   public String execute() throws Exception {
       map = new HashMap<String, String>();
       map.put("abc", "abc");
       map.put("xyz", "xyz");
       return SUCCESS;
   }
}
Run Code Online (Sandbox Code Playgroud)

对于映射到成功的jsp,使用这样的东西

<s:select list = "map" name = "name" label = "Name" headerKey="" headerValue = "Enter Value"/>
Run Code Online (Sandbox Code Playgroud)