title: retrieve value in selectbox in struts2
body: <pre><code>package vaannila;
  
  import java.util.ArrayList;
  
  import com.opensymphony.xwork2.ActionSupport;
  
  public class RegisterAction extends ActionSupport {
  
      private String userName;
  
      private String password;
  
      private String gender;
  
      private String about;
  
      private String country;
  
      private ArrayList&lt;Country&gt; countryList;
  
      private String[] community;
  
      private ArrayList&lt;String&gt; communityList;
  
      private Boolean  mailingList;
  
      public String populate() {
  
          countryList = new ArrayList&lt;Country&gt;();
          countryList.add(new Country(1, "India"));
          countryList.add(new Country(2, "USA"));
          countryList.add(new Country(3, "France"));
  
          communityList = new ArrayList&lt;String&gt;();
          communityList.add("Java");
          communityList.add(".Net");
          communityList.add("SOA");
  
          community = new String[]{"Java",".Net"};
          mailingList = true;
  
          return "populate";
      }
  
      @Override
      public String execute() {
          return SUCCESS;
      }
  
      public String getUserName() {
          return userName;
      }
  
      public void setUserName(String userName) {
          this.userName = userName;
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getGender() {
          return gender;
      }
  
      public void setGender(String gender) {
          this.gender = gender;
      }
  
      public String getAbout() {
          return about;
      }
  
      public void setAbout(String about) {
          this.about = about;
      }
  
      public String getCountry() {
          return country;
      }
  
      public void setCountry(String country) {
          this.country = country;
      }
  
      public ArrayList&lt;Country&gt; getCountryList() {
          return countryList;
      }
  
      public void setCountryList(ArrayList&lt;Country&gt; countryList) {
          this.countryList = countryList;
      }
  
      public String[] getCommunity() {
          return community;
      }
  
      public void setCommunity(String[] community) {
          this.community = community;
      }
  
      public ArrayList&lt;String&gt; getCommunityList() {
          return communityList;
      }
  
      public void setCommunityList(ArrayList&lt;String&gt; communityList) {
          this.communityList = communityList;
      }
  
      public Boolean getMailingList() {
          return mailingList;
      }
  
      public void setMailingList(Boolean mailingList) {
          this.mailingList = mailingList;
      }
  
  }
  </code></pre>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>      &lt;s:select name="country" list="countryList" listKey="countryId"
      listValue="countryName" headerKey="0" headerValue="Country"
      label="Select a country" /&gt;
  </code></pre>
  
  <p><strong>success.jsp</strong></p>
  
  <pre><code>        Country: &lt;s:property value="country" /&gt;&lt;br&gt;
  </code></pre>
  
  <p>When I select a value in textbox,it is retrieving id and not name i.e when I select india I am getting 1 instead of India.</p>
  
  <p>Is there any way to retrieve name instead of id?</p>