title: Struts 2 Drop Down Example Problem
body: <p>i am trying to work on a drop down list using struts2  tag. But till now i am unsuccessful: below is the .jsp page, the action class, the struts.xml file and all relevant codes. Any help will be greatly appreciated. Thank you.</p>
  
  <p><strong>Note: I am getting this error :-> tag 'select', field 'list': The requested list key 'country' could not be resolved as a collection/array/map/enumeration/iterator type. Example: people or people.{name} - [unknown location]</strong></p>
  
  <p>...........<br>
  Index.jsp : <br>
  .............<br></p>
  
  <p>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%>
  &lt;%@taglib uri="/struts-tags" prefix="s" %>
  </p>
  
  <pre><code>    &lt;h3&gt;Struts 2: UI Tag Example - Registration Page Demo &lt;/h3&gt;&lt;hr&gt;
      &lt;s:form action="register"&gt;
          &lt;s:select label="Country" list="country" listKey="countryAbbr" listValue="countryName" /&gt;
          &lt;s:submit/&gt;
      &lt;/s:form&gt;
  </code></pre>
  
  <p>......................<br>
  struts.xml:<br>
  ......................<br>
  </p>
  
  <pre><code>&lt;package name="com.uitagdemo" extends="struts-default"&gt;
      &lt;action name="register" class="com.uitagdemo.RegisterAction" &gt;
          &lt;result name="success"&gt;/success.jsp&lt;/result&gt;
          &lt;result name="input"&gt;/index.jsp&lt;/result&gt;
      &lt;/action&gt;
  &lt;/package&gt;
  </code></pre>
  
  <p></p>
  
  <p>...........................<br>
  RegisterAction.java <br>
  ...........................<br>
  public class RegisterAction extends ActionSupport {</p>
  
  <pre><code>private List&lt;Country&gt; country;
  
  public String execute() {
      return SUCCESS;
  }
  
  public List&lt;Country&gt; getCountry(){
  
      country = new ArrayList&lt;Country&gt;();
      country.add(new Country("IN", "INDIA"));
      country.add(new Country("US", "USA"));
      country.add(new Country("FR", "FRANCE"));
      return country;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>.......................<br>
  success.jsp<br>
  .......................<br></p>
  
  <p>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%>
  &lt;%@taglib uri="/struts-tags" prefix="s" %>
  </p>
  
  <p>
      
          
          Struts 2: UI Tag Example
      
      
          <h3>Struts 2: UI Tag Example - Registration Page Demo  </h3><hr></p>
  
  <pre><code>    Country: &lt;s:property value="country" /&gt;&lt;br&gt;
  
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>......................<br>
  Country.java<br>
  ......................<br></p>
  
  <p>public class Country {</p>
  
  <pre><code>private String countryAbbr;
  private String countryName;
  
  public Country() {
  }
  
  public Country(String countryAbbr, String countryName) {
      this.countryAbbr = countryAbbr;
      this.countryName = countryName;
  }
  
  public String getCountryName() {
      return countryName;
  }
  
  public void setCountryName(String countryName) {
      this.countryName = countryName;
  }
  
  public String getCountryAbbr() {
      return countryAbbr;
  }
  
  public void setCountryAbbr(String countryAbbr) {
      this.countryAbbr = countryAbbr;
  }
  </code></pre>
  
  <p>}</p>